Skip to content

Commit cf01274

Browse files
Cyprien AutexierCyprien Autexier
authored andcommitted
introducing modclean
1 parent 3b029e2 commit cf01274

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

node-modclean.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
var tasks = require('./tasks.js');
2+
var series = require("async/series");
3+
var path = require("path");
4+
var fs = require("fs");
5+
6+
var runModclean = (project) => {
7+
return (done) => {
8+
9+
if (fs.existsSync(path.join(project.directory, "node_modules"))) {
10+
var exec = require('child_process').exec;
11+
var child = exec('npm run modclean -r', {
12+
cwd: project.directory
13+
}, (error, stdout, stderr) => {
14+
if (error) {
15+
console.error(`exec error: ${error}`);
16+
done(error);
17+
return;
18+
}
19+
20+
console.log(`modclean done for ${project.name}`);
21+
22+
if (stdout) {
23+
console.log(stdout);
24+
}
25+
26+
if (stderr) {
27+
console.error(stderr);
28+
}
29+
30+
done();
31+
});
32+
} else {
33+
console.log(`modclean skipped for ${project.name}`);
34+
done();
35+
}
36+
};
37+
}
38+
39+
var cleanTasks = tasks.getTasks().map(runModclean);
40+
41+
series(cleanTasks, (err) => {
42+
if (err) {
43+
console.error("Failed to run modclean");
44+
throw err;
45+
}
46+
});

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"bin": {
66
"vsts-build-tools-clean": "./run/vsts-build-tools-clean",
77
"vsts-build-tools-install": "./run/vsts-build-tools-install",
8+
"vsts-build-tools-node-modclean": "./run/vsts-build-tools-node-modeclean",
89
"vsts-build-tools-package": "./run/vsts-build-tools-package",
910
"vsts-build-tools-prebuild": "./run/vsts-build-tools-prebuild"
1011
},
@@ -20,6 +21,7 @@
2021
"jasmine": "2.4.1",
2122
"semver": "5.3.0",
2223
"tfx-cli": "0.3.23",
23-
"glob": "7.0.5"
24+
"glob": "7.0.5",
25+
"modclean": "2.1.0"
2426
}
2527
}

run/vsts-build-tools-node-modclean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../node-modclean');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@node "%~dpn0" %*

0 commit comments

Comments
 (0)