forked from CopyTranslator/CopyTranslator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.js
More file actions
27 lines (24 loc) · 682 Bytes
/
clean.js
File metadata and controls
27 lines (24 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const path = require("path");
const fs = require("fs");
const ignores = [];
function walk(dir) {
var results = [];
var list = fs.readdirSync(dir);
list.forEach(function (file) {
file = path.join(dir, file);
var stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(walk(file));
} else {
// 过滤后缀名(可按你需求进行新增)
if (
path.extname(file) === ".js" &&
!ignores.includes(path.basename(file))
) {
results.push(path.resolve(__dirname, file));
}
}
});
return results;
}
walk(path.join(__dirname, "src")).forEach((file) => fs.unlinkSync(file));