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
|
module.exports = (repo, branch, callback) => {
const spinner = ora("Downloading package...").start();
if (os.platform() === "win32") {
git = require('child_process').execSync("where git").toString().trim();
} else {
git = require('child_process').execSync("which git").toString().trim();
}
cp = require('child_process').spawn(git, ["clone", "--progress", "-b", branch, "--", repo, home + "/buildroot"], {/*stdio: "inherit"*/});
cp.stdout.on('data', (data) => {
spinner.text = data.toString().trim().split("\n")[data.toString().trim().split("\n").length - 1];
})
cp.stderr.on('data', (data) => {
spinner.text = data.toString().trim().split("\n")[data.toString().trim().split("\n").length - 1].replace(/[^0-9a-zA-z: -,.!? \/\(\)]*/gm, "");
})
cp.on('close', (code) => {
if (code !== 0) {
throw new Error("Process exited with code " + code);
} else {
spinner.succeed("Downloading package... done");
callback();
}
})
}
|