mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-03 08:35:29 +02:00
9289dbdf77
* Refactoring MdToHtml to avoid manually rendering tokens * Minor fix * Fixed loading of resources * Handle clicking on checkboxes * Added back Katex support * Fixed issues with Katex and note rendering * Added back support for links * Restored code block highlighting support * clean up * Applying update to mobile * Fixed handling of links and cleaned up to share more code between mobile and desktop * Restored content caching and improved handling of additional assets * Clean up and a few fixes * Applied more updates to mobile and added code highlighting support
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
const fs = require('fs-extra');
|
|
const spawnSync = require('child_process').spawnSync;
|
|
|
|
const babelPath = __dirname + '/node_modules/.bin/babel' + (process.platform === 'win32' ? '.cmd' : '');
|
|
const basePath = __dirname + '/../..';
|
|
const guiPath = __dirname + '/gui';
|
|
|
|
function fileIsNewerThan(path1, path2) {
|
|
if (!fs.existsSync(path2)) return true;
|
|
|
|
const stat1 = fs.statSync(path1);
|
|
const stat2 = fs.statSync(path2);
|
|
|
|
return stat1.mtime > stat2.mtime;
|
|
}
|
|
|
|
fs.readdirSync(guiPath).forEach((filename) => {
|
|
const jsxPath = guiPath + '/' + filename;
|
|
const p = jsxPath.split('.');
|
|
if (p.length <= 1) return;
|
|
const ext = p[p.length - 1];
|
|
if (ext !== 'jsx') return;
|
|
p.pop();
|
|
|
|
const basePath = p.join('.');
|
|
|
|
const jsPath = basePath + '.min.js';
|
|
|
|
if (fileIsNewerThan(jsxPath, jsPath)) {
|
|
console.info('Compiling ' + jsxPath + '...');
|
|
const result = spawnSync(babelPath, ['--presets', 'react', '--out-file', jsPath, jsxPath]);
|
|
if (result.status !== 0) {
|
|
const msg = [];
|
|
if (result.stdout) msg.push(result.stdout.toString());
|
|
if (result.stderr) msg.push(result.stderr.toString());
|
|
console.error(msg.join('\n'));
|
|
if (result.error) console.error(result.error);
|
|
process.exit(result.status);
|
|
}
|
|
}
|
|
});
|
|
|
|
const libContent = [
|
|
fs.readFileSync(basePath + '/ReactNativeClient/lib/string-utils-common.js', 'utf8'),
|
|
fs.readFileSync(basePath + '/ReactNativeClient/lib/markJsUtils.js', 'utf8'),
|
|
fs.readFileSync(basePath + '/ReactNativeClient/lib/MdToHtml/webviewLib.js', 'utf8'),
|
|
];
|
|
|
|
fs.writeFileSync(__dirname + '/gui/note-viewer/lib.js', libContent.join('\n'), 'utf8');
|