mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 16:15:41 +01:00
Refactor project shape
This commit is contained in:
parent
5c70cefbad
commit
92af97ca38
25 changed files with 96 additions and 104 deletions
25
scripts/copy.js
Normal file
25
scripts/copy.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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]}`);
|
||||
21
scripts/rmdir.js
Normal file
21
scripts/rmdir.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const target = path.join(process.cwd(), process.argv[2]);
|
||||
rmDir(target);
|
||||
console.log(`Deleted ${process.argv[2]}`);
|
||||
|
||||
function rmDir(dirPath) {
|
||||
let entries = fs.readdirSync(dirPath);
|
||||
if (entries.length > 0) {
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
var filePath = path.join(dirPath, entries[i]);
|
||||
if (fs.statSync(filePath).isFile()) {
|
||||
fs.unlinkSync(filePath);
|
||||
} else {
|
||||
rmDir(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
fs.rmdirSync(dirPath);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue