Skip to content

Instantly share code, notes, and snippets.

@mfyz
Created February 14, 2021 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfyz/b48e512c6c135d4ae0e3ee55e09cde4a to your computer and use it in GitHub Desktop.
Save mfyz/b48e512c6c135d4ae0e3ee55e09cde4a to your computer and use it in GitHub Desktop.
Show git remotes of each project in each folder (nodejs)
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