Created
February 14, 2021 22:24
-
-
Save mfyz/b48e512c6c135d4ae0e3ee55e09cde4a to your computer and use it in GitHub Desktop.
Show git remotes of each project in each folder (nodejs)
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 path = require('path') | |
const { execSync, spawnSync } = require('child_process') | |
const runCmd = (cmd) => { | |
try { | |
const res = spawnSync(cmd, [], { shell: true }) | |
return res.stdout.toString() | |
} | |
catch (err) { | |
return false | |
} | |
} | |
const root = './' | |
const ls = fs.readdirSync(root) | |
const results = [] | |
ls.forEach((dir) => { | |
if (fs.lstatSync(path.join(root, dir)).isDirectory()) { | |
const result = runCmd(`cd ${path.join(root, dir)} && git remote -v && cd ..`, { stdio: 'inherit' }) | |
const gitRemote = result && result.split('\t')[1].split(' ')[0] | |
// if (gitRemote && gitRemote.indexOf('ship.nomadinteractive.co') > 0) { | |
results.push([ | |
dir, | |
(gitRemote || '-') | |
]) | |
// } | |
} | |
}) | |
console.table(results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment