Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
1,723 additions
and
3,123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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; | ||
if (theme[0] === '.') { | ||
themePath = path.join(process.cwd(), theme, 'index.js'); | ||
} else { | ||
themePath = path.resolve(process.cwd(), 'node_modules', theme); | ||
} | ||
const render = require(themePath).render; | ||
|
||
if (typeof render !== 'function') { | ||
console.log( | ||
chalk.yellow('Could not run the render function from local theme.'), | ||
); | ||
return Promise.reject(new Error(`Can't render with "${theme}"'s theme`)); | ||
} | ||
|
||
return render(resumeJson); | ||
}; |
Oops, something went wrong.