diff --git a/lib/builder.js b/lib/builder.js index 968decaa..efca364e 100644 --- a/lib/builder.js +++ b/lib/builder.js @@ -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]; diff --git a/lib/render-html.js b/lib/render-html.js index 373599ba..c5065f80 100644 --- a/lib/render-html.js +++ b/lib/render-html.js @@ -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] }); diff --git a/lib/render-html.test.js b/lib/render-html.test.js index b068d12f..78038ad9 100644 --- a/lib/render-html.test.js +++ b/lib/render-html.test.js @@ -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; } @@ -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' }), @@ -40,20 +43,5 @@ describe('renderHTML', () => { '', ); }); - - 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(''); - }); }); });