aboutsummaryrefslogtreecommitdiff
path: root/hooks/clone.js
diff options
context:
space:
mode:
Diffstat (limited to 'hooks/clone.js')
-rw-r--r--hooks/clone.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/hooks/clone.js b/hooks/clone.js
new file mode 100644
index 0000000..77c5a33
--- /dev/null
+++ b/hooks/clone.js
@@ -0,0 +1,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();
+ }
+ })
+} \ No newline at end of file