Skip to content

Commit b24a94b

Browse files
committed
Revert "fix(theme): fix serving and exporting local themes (#537)"
This reverts commit 16eae28.
1 parent 44cce17 commit b24a94b

File tree

3 files changed

+10
-24
lines changed

3 files changed

+10
-24
lines changed

lib/builder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const themeServer =
33
const fs = require('fs');
44
const request = require('superagent');
55
const chalk = require('chalk');
6-
const renderHtml = require('./render-html').default;
6+
const renderHtml = require('./render-html');
77

88
const denormalizeTheme = (value) => {
99
return value.match(/jsonresume-theme-(.*)/)[1];

lib/render-html.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ export default async ({ resume, themePath }) => {
1010
const cwd = process.cwd();
1111
let path;
1212
if (themePath[0] === '.') {
13-
path = tryResolve(require('path').join(cwd, themePath), { paths: [cwd] });
14-
if (!path) {
15-
throw new Error(
16-
`Theme ${themePath} could not be resolved relative to ${cwd}`,
17-
);
18-
}
13+
path = tryResolve(path.join(cwd, themePath), { paths: [cwd] });
14+
throw new Error(
15+
`Theme ${themePath} could not be resolved relative to ${cwd}`,
16+
);
1917
}
2018
if (!path) {
2119
path = tryResolve(themePath, { paths: [cwd] });

lib/render-html.test.js

+5-17
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ describe('renderHTML', () => {
55
const originalRequireResolve = require.resolve;
66
const mockThemePath = 'mock/path/to/jsonresume-theme-even';
77
require.resolve = (...args) => {
8+
if (args[0] === 'jsonresume-theme-even') {
9+
return mockThemePath;
10+
}
811
if (args[0] === 'jsonresume-theme-even') {
912
return mockThemePath;
1013
}
@@ -22,13 +25,13 @@ describe('renderHTML', () => {
2225
},
2326
};
2427

25-
it('should reject when theme is not available', async () => {
28+
it('should reject when theme is not availlable', async () => {
2629
await expect(
2730
renderHTML({ resume, themePath: 'unknown' }),
2831
).rejects.toBeTruthy();
2932
});
3033

31-
describe('should render html when theme is available', () => {
34+
describe('should render html when theme is availlable', () => {
3235
it('with long theme name', async () => {
3336
expect(
3437
await renderHTML({ resume, themePath: 'jsonresume-theme-even' }),
@@ -40,20 +43,5 @@ describe('renderHTML', () => {
4043
'<!doctype html>',
4144
);
4245
});
43-
44-
it('should reject theme with invalid path', async () => {
45-
await expect(
46-
renderHTML({ resume, themePath: './unknown' }),
47-
).rejects.toBeTruthy();
48-
});
49-
50-
it('with local theme path', async () => {
51-
expect(
52-
await renderHTML({
53-
resume,
54-
themePath: './node_modules/jsonresume-theme-even',
55-
}),
56-
).toStartWith('<!doctype html>');
57-
});
5846
});
5947
});

0 commit comments

Comments
 (0)