-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
45 lines (39 loc) · 1.07 KB
/
utils.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
41
42
43
44
45
const child = require("child_process");
const path = require("path");
const Types = require("./types");
/**
* Deletes node_modules in project directory using robocopy.
* @param {Types.Project} project
*/
const removeNodeModulesRobocopy = (project) => {
return new Promise((resolve, reject) => {
child.exec("mkdir emptydir", (error) => {
if (error) {
reject(`Error creating emptydir: ${error}`);
return;
}
child.exec(
`robocopy emptydir ${path.join(dir, "node_modules")} /mir`,
(error) => {
if (error && error.code !== 1) {
reject(`Error during robocopy: ${error}`);
return;
}
child.exec("rmdir emptydir", (error) => {
if (error) {
reject(`Error removing emptydir: ${error}`);
return;
}
console.log(
`node_modules in ${project.name} deleted successfully!`
);
resolve();
});
}
);
});
});
};
module.exports = {
removeNodeModulesRobocopy,
};