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');
|
2019-07-30 09:35:42 +02:00
|
|
|
// 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`);
|
2019-07-30 09:35:42 +02:00
|
|
|
|
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);
|
2019-07-30 09:35:42 +02:00
|
|
|
});
|