-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathuseless.js
More file actions
33 lines (29 loc) · 803 Bytes
/
useless.js
File metadata and controls
33 lines (29 loc) · 803 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
28
29
30
31
32
33
/**
* 检查英文文档修改中,未使用的图片并删除
*/
const { execSync } = require("child_process");
const path = require("path");
const fs = require("fs");
const DIR = "./docs/en";
execSync(
`find ${DIR} -type f \\( -iname \\*.jpg -o -iname \\*.png -o -iname \\*.gif \\) -not -path "./.vuepress/*" -not -path "./.git/*" > temp.log`,
{ encoding: "utf-8" }
);
const files = fs.readFileSync("./temp.log", { encoding: "utf-8" }).split("\n");
files.forEach(file => {
if (!file) {
return;
}
// console.log(`Check ${file}`);
const filename = file.split("/").pop();
try {
execSync(`grep -R "/${filename}" ${DIR}`, {
encoding: "utf-8"
});
} catch (e) {
console.log(file);
// execSync(`rm -rf ${file}`, {
// encoding: "utf-8"
// });
}
});