Skip to content

Commit

Permalink
Added clone command
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanth-hk committed Mar 31, 2020
1 parent 07dd514 commit af3eb08
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions commands/misc/clone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// modules
const { spawn } = require("child_process");

function clone(urls) {
if (!urls[0]) {
console.log("url not given")
return
}
let cmd;
let folderName = urls[0].substring(urls[0].lastIndexOf("/") + 1, urls[0].lastIndexOf("."))
if (urls[1]) {
if (urls[2]) {
cmd = `git clone ${urls[0]} && cd ${folderName} && git remote add ${urls[2]} ${urls[1]}`
} else {
cmd = `git clone ${urls[0]} && cd ${folderName} && git remote add upstream ${urls[1]}`
}
} else {
cmd = `git clone ${urls[0]}`
}

let command = spawn(cmd, [], { shell: true });

command.stderr.on("data", data => {
console.log(`${data}`)
});
}

module.exports = clone;

0 comments on commit af3eb08

Please sign in to comment.