forked from krausest/js-framework-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanup.js
40 lines (34 loc) · 1.15 KB
/
cleanup.js
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
34
35
36
37
38
39
40
const fs = require("fs");
const path = require("path");
/**
* @param {string} dir
*/
function rmIfExists(dir) {
if (fs.existsSync(dir)) {
console.log("Cleaning", dir);
fs.rmSync(dir, { recursive: true });
}
}
/**
* @param {string} basePath
* @param {string} keyedTypes
*/
function cleanFrameworkDirectories(basePath, keyedTypes) {
for (const keyedType of keyedTypes) {
const frameworkDir = path.resolve(basePath, keyedType);
const directories = fs.readdirSync(frameworkDir);
for (const directory of directories) {
const frameworkPath = path.resolve(frameworkDir, directory);
console.log("cleaning ", frameworkPath);
rmIfExists(path.join(frameworkPath, "package-lock.json"));
rmIfExists(path.join(frameworkPath, "yarn.lock"));
rmIfExists(path.join(frameworkPath, "node_modules"));
rmIfExists(path.join(frameworkPath, "dist"));
rmIfExists(path.join(frameworkPath, "elm-stuff"));
rmIfExists(path.join(frameworkPath, "bower_components"));
}
}
}
const keyedTypes = ["keyed", "non-keyed"];
const frameworksPath = path.resolve("frameworks");
cleanFrameworkDirectories(frameworksPath, keyedTypes);