1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-27 10:32:58 +02:00
joplin/Tools/copycss.js

31 lines
1013 B
JavaScript
Raw Normal View History

2018-02-04 19:12:24 +02:00
const fs = require('fs-extra');
const cwd = process.cwd();
2019-09-19 23:51:18 +02:00
const outputDir = `${cwd}/lib/csstojs`;
2018-02-04 19:12:24 +02:00
async function createJsFromCss(name, filePath) {
let css = await fs.readFile(filePath, 'utf-8');
// eslint-disable-next-line no-useless-escape
2018-02-04 19:12:24 +02:00
css = css.replace(/\`/g, '\\`');
2019-09-19 23:51:18 +02:00
const js = `module.exports = \`${css}\`;`;
2018-02-04 19:12:24 +02:00
2019-09-19 23:51:18 +02:00
const outputPath = `${outputDir}/${name}.css.js`;
2018-02-04 19:12:24 +02:00
await fs.writeFile(outputPath, js);
}
async function main(argv) {
await fs.mkdirp(outputDir);
2019-09-19 23:51:18 +02:00
await createJsFromCss('katex', `${cwd}/node_modules/katex/dist/katex.min.css`);
await createJsFromCss('hljs-atom-one-light', `${cwd}/node_modules/highlight.js/styles/atom-one-light.css`);
await createJsFromCss('hljs-atom-one-dark-reasonable', `${cwd}/node_modules/highlight.js/styles/atom-one-dark-reasonable.css`);
2018-02-04 19:12:24 +02:00
if (argv.indexOf('--copy-fonts') >= 0) {
2019-09-19 23:51:18 +02:00
await fs.copy(`${cwd}/node_modules/katex/dist/fonts`, `${cwd}/gui/note-viewer/fonts`);
2018-02-04 19:12:24 +02:00
}
}
main(process.argv).catch((error) => {
console.error(error);
process.exit(1);
});