Skip to content

Commit

Permalink
Revert "fix(theme): fix serving and exporting local themes (#537)"
Browse files Browse the repository at this point in the history
This reverts commit 16eae28.
  • Loading branch information
thomasdavis committed Apr 3, 2024
1 parent 44cce17 commit b24a94b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const themeServer =
const fs = require('fs');
const request = require('superagent');
const chalk = require('chalk');
const renderHtml = require('./render-html').default;
const renderHtml = require('./render-html');

const denormalizeTheme = (value) => {
return value.match(/jsonresume-theme-(.*)/)[1];
Expand Down
10 changes: 4 additions & 6 deletions lib/render-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ export default async ({ resume, themePath }) => {
const cwd = process.cwd();
let path;
if (themePath[0] === '.') {
path = tryResolve(require('path').join(cwd, themePath), { paths: [cwd] });
if (!path) {
throw new Error(
`Theme ${themePath} could not be resolved relative to ${cwd}`,
);
}
path = tryResolve(path.join(cwd, themePath), { paths: [cwd] });
throw new Error(
`Theme ${themePath} could not be resolved relative to ${cwd}`,
);
}
if (!path) {
path = tryResolve(themePath, { paths: [cwd] });
Expand Down
22 changes: 5 additions & 17 deletions lib/render-html.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ describe('renderHTML', () => {
const originalRequireResolve = require.resolve;
const mockThemePath = 'mock/path/to/jsonresume-theme-even';
require.resolve = (...args) => {
if (args[0] === 'jsonresume-theme-even') {
return mockThemePath;
}
if (args[0] === 'jsonresume-theme-even') {
return mockThemePath;
}
Expand All @@ -22,13 +25,13 @@ describe('renderHTML', () => {
},
};

it('should reject when theme is not available', async () => {
it('should reject when theme is not availlable', async () => {
await expect(
renderHTML({ resume, themePath: 'unknown' }),
).rejects.toBeTruthy();
});

describe('should render html when theme is available', () => {
describe('should render html when theme is availlable', () => {
it('with long theme name', async () => {
expect(
await renderHTML({ resume, themePath: 'jsonresume-theme-even' }),
Expand All @@ -40,20 +43,5 @@ describe('renderHTML', () => {
'<!doctype html>',
);
});

it('should reject theme with invalid path', async () => {
await expect(
renderHTML({ resume, themePath: './unknown' }),
).rejects.toBeTruthy();
});

it('with local theme path', async () => {
expect(
await renderHTML({
resume,
themePath: './node_modules/jsonresume-theme-even',
}),
).toStartWith('<!doctype html>');
});
});
});

0 comments on commit b24a94b

Please sign in to comment.