I need a reliable way to clone a github repo and paste it into a local directory using node.js and any necessary npm packages.
This code is using the nodegit library and doesn't work to clone a github repo. it creates a single folder named .git and copies none of the files from the repo. I have tried several libraries most of which have extremely complicated code or don't work. This was working before but now isn't. (it goes on and off as it pleases). pls help, I need a reliable code that clones a github repo from url and pastes it into a local directory. Thank you.
var nodegit = require('nodegit'),
path = require('path');
var url = "https://github.com/atomicptr/dauntless-builder", //also tried https://github.com/atomicptr/dauntless-builder.git
local = "C:/data",
cloneOpts = {};
nodegit.Clone(url, local, cloneOpts).then(function (repo) {
console.log("cloning succesful!");
console.log("Cloned " + path.basename(url) + " to " + repo.workdir());
}).catch(function (err) {
console.log(err);
});
this code shows no errors, yet doesn't actually work to clone the repo.
You can use shelljs for this.
const shell = require('shelljs')
const path = 'absolute/path/to/folder'
shell.cd(path)
shell.exec('git clone https://github.com/atomicptr/dauntless-builder')