You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
monaco-editor/scripts/copy.js

26 lines
591 B
JavaScript

const fs = require('fs');
const path = require('path');
const source = path.join(process.cwd(), process.argv[2]);
const destination = path.join(process.cwd(), process.argv[3]);
// ensure target dir
(function () {
let dirs = [];
let dirname = path.dirname(destination);
while (dirname !== process.cwd()) {
dirs.push(dirname);
dirname = path.dirname(dirname);
}
dirs.reverse();
dirs.forEach((dir) => {
try { fs.mkdirSync(dir); } catch (err) { }
})
})();
fs.writeFileSync(destination, fs.readFileSync(source));
console.log(`Copied ${process.argv[2]} to ${process.argv[3]}`);