mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
71efff6827
* Update eslint config * Applied linter to lib * Applied eslint config to CliClient/app * Removed prettier due to https://github.com/prettier/prettier/pull/4765 * First pass on test units * Applied linter config to test units * Applied eslint config to clipper * Applied to plugin dir * Applied to root of ElectronClient * Applied on RN root * Applied on CLI root * Applied on Clipper root * Applied config to tools * test hook * test hook * test hook * Added pre-commit hook * Applied rule no-trailing-spaces * Make sure root packages are installed when installing sub-dir * Added doc
28 lines
937 B
JavaScript
28 lines
937 B
JavaScript
// React Native WebView cannot load external JS files, however it can load
|
|
// arbitraty JS via the injectedJavaScript property. So we use this to load external
|
|
// files: First here we convert the JS file to a plain string, and that string
|
|
// is then loaded by eg. the Mermaid plugin, and finally injected in the WebView.
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
const cwd = process.cwd();
|
|
const outputDir = cwd + '/lib/rnInjectedJs';
|
|
const rnDir = __dirname + '/../ReactNativeClient';
|
|
|
|
async function copyJs(name, filePath) {
|
|
const js = await fs.readFile(filePath, 'utf-8');
|
|
const json = 'module.exports = ' + JSON.stringify(js) + ';';
|
|
const outputPath = outputDir + '/' + name + '.js';
|
|
await fs.writeFile(outputPath, json);
|
|
}
|
|
|
|
async function main(argv) {
|
|
await fs.mkdirp(outputDir);
|
|
await copyJs('webviewLib', rnDir + '/lib/renderers/webviewLib.js');
|
|
}
|
|
|
|
main(process.argv).catch((error) => {
|
|
console.error(error);
|
|
process.exit(1);
|
|
});
|