测试:从vj4的自动迁移脚本(未完成)

This commit is contained in:
undefined committed 2020-05-10 18:57:03 +08:00
1 parent cedb427dc9
commit 41125c6929
11 files changed
+185 -24

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
const fs = require('fs');
const path = require('path');
exports.root = (name) => path.resolve(__dirname, '..', name);
exports.exist = (name) => {
try {
fs.statSync(exports.root(name));
} catch (e) {
return false;
}
return true;
};
exports.rmdir = function rmdir(p, recursive = true) {
if (!fs.existsSync(p)) return;
if (recursive) {
fs.readdirSync(p).forEach((file) => {
const curPath = `${p}/${file}`;
if (fs.statSync(curPath).isDirectory()) rmdir(curPath);
else fs.unlinkSync(curPath);
});
}
fs.rmdirSync(p);
};
exports.ignoreFailure = function ignoreFailure(func, ...params) {
try {
func(...params);
} catch (e) { } // eslint-disable-line no-empty
};