Skip to content

Instantly share code, notes, and snippets.

@MatheusR42
Created March 10, 2021 00:50
Show Gist options
  • Save MatheusR42/e6c3d6d77f6c7189198b42b0ce2fea08 to your computer and use it in GitHub Desktop.
Save MatheusR42/e6c3d6d77f6c7189198b42b0ce2fea08 to your computer and use it in GitHub Desktop.
Batch clone repos
const fs = require('fs');
const util = require('util');
const path = require('path');
const exec = util.promisify(require('child_process').exec);
const appDir = path.dirname(require.main.filename);
const repos = [
'git@github.com:MatheusR42/repo-name-1.git',
'git@github.com:MatheusR42/repo-name-2.git',
]
repos.forEach(async repo => {
try {
if (!fs.existsSync(`${appDir}/${folderName}`)) {
const { stdout, stderr } = await exec(`cd ${appDir} && git clone ${repo}`);
console.log('stdout:', stdout);
console.log('stderr:', stderr);
}
} catch (e) {
console.log(folderName);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment