Skip to content

Commit

Permalink
fix: caused regressions in fetching relative themes
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdavis committed Nov 18, 2020
1 parent 50688d4 commit 2ec202b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/builder/index.js
Expand Up @@ -52,6 +52,7 @@ module.exports = function resumeBuilder(theme, dir, resumeFilename, cb) {
const html = await renderHtml(resumeJson, theme);
cb(null, html);
} catch (err) {
console.log(err);
console.log(
chalk.yellow('Could not run the render function from local theme.'),
);
Expand Down
27 changes: 17 additions & 10 deletions lib/render-html/index.js
@@ -1,17 +1,24 @@
const path = require('path');
const chalk = require('chalk');

module.exports = async function renderHtml(resumeJson, theme) {
if (!theme.match('jsonresume-theme-.*')) {
theme = 'jsonresume-theme-' + theme;
}
let themePath;
const getThemePkg = (theme) => {
if (theme[0] === '.') {
themePath = path.join(process.cwd(), theme, 'index.js');
} else {
themePath = path.resolve(process.cwd(), 'node_modules', theme);
theme = path.join(process.cwd(), theme, 'index.js');
}
try {
const themePkg = require(theme);
return themePkg;
} catch (err) {
// Theme not installed
console.log(
'You have to install this theme relative to the folder to use it e.g. `npm install ' +
theme +
'`',
);
process.exit();
}
const render = require(themePath).render;
};
module.exports = async function renderHtml(resumeJson, theme) {
const render = getThemePkg(theme).render;

if (typeof render !== 'function') {
console.log(
Expand Down

0 comments on commit 2ec202b

Please sign in to comment.