forked from krausest/js-framework-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanup.js
40 lines (36 loc) · 1.09 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
var _ = require('lodash');
var exec = require('child_process').execSync;
var fs = require('fs');
var commandExists = require('command-exists');
const path = require('path');
var installCommand = 'npm install';
var excludedDirectories = ['css', 'dist','node_modules','webdriver-java'];
function rmIfExists(base, name) {
let dir = path.join(base, name);
if(fs.existsSync(dir)) {
let cleanCommand = 'rm -r '+name;
console.log("Executing "+cleanCommand+" in "+base);
exec(cleanCommand, {
cwd: base,
stdio: 'inherit'
});
}
}
_.each(fs.readdirSync('.'), function(name) {
if(fs.statSync(name).isDirectory() && name[0] !== '.' && excludedDirectories.indexOf(name)==-1) {
if(fs.existsSync(name+"/node_modules")) {
let cleanCommand = 'rm -r node_modules';
console.log("Executing "+cleanCommand+" in "+name);
exec(cleanCommand, {
cwd: name,
stdio: 'inherit'
});
}
rmIfExists(name, "package-lock.json");
rmIfExists(name, "yarn.lock");
rmIfExists(name, "dist");
rmIfExists(name, "elm-stuff");
rmIfExists(name, "bower_components");
rmIfExists(name, "node_modules");
}
});