Created
March 10, 2021 00:50
-
-
Save MatheusR42/e6c3d6d77f6c7189198b42b0ce2fea08 to your computer and use it in GitHub Desktop.
Batch clone repos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [ | |
'[email protected]:MatheusR42/repo-name-1.git', | |
'[email protected]: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