mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
测试:从vj4的自动迁移脚本(未完成)
This commit is contained in:
1 parent
cedb427dc9
commit
41125c6929
11 files changed
+185
-24
No files matched your search
@@ -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
|
||||
};
|
||||
Reference in new issue
Block a user