embark/packages/cockpit/cockpit-ui/scripts/copy-monaco-to-public.js
Michael Bradley b74debfb8d refactor(@cockpit/ui): use non-ejected create-react-app (#1910)
Change components/TexEditor re: how monaco-editor is loaded, since difficulties
with monaco-editor were the original motivation for "ejecting" the CRA setup.

Specify "nohoist" for `embark-ui/react-scripts` and all its dependencies to
avoid potential headaches when upgrading the react-scripts, i.e. upgrading to
newer versions of create-react-app.
2019-09-17 17:32:45 +02:00

30 lines
824 B
JavaScript

/* global __dirname process require */
const findUp = require('find-up');
const {copy, ensureDir} = require('fs-extra');
const path = require('path');
const {promisify} = require('util');
const rimraf = promisify(require('rimraf'));
async function main() {
const which = process.argv[2] || 'min';
const monacoDir = await findUp('node_modules/monaco-editor', {type: 'directory'});
const vsDir = path.join(__dirname, '..', 'public', 'vsdir');
const innerVsDir = path.join(vsDir, 'vsdir');
await rimraf(vsDir);
await ensureDir(innerVsDir);
await copy(path.join(monacoDir, which), innerVsDir);
const minMapsDir = path.join(vsDir, 'min-maps');
await rimraf(minMapsDir);
if (which === 'min') {
await ensureDir(minMapsDir);
await copy(path.join(monacoDir, 'min-maps'), minMapsDir);
}
}
main();