popomore / github-labels

Add github labels automatically
177 stars 20 forks source link

Programmatic usage #22

Open RichardLitt opened 7 years ago

RichardLitt commented 7 years ago

I would like to be able to run this programmatically without needing to use the CLI every time, as I maintain a lot of repos and sometimes just want to ensure that they all have the right labels. I am pretty sure this isn't right, as it tends to shut down my Spotify music when I run it (fun!).

const exec = require('child_process').exec
const githubRepos = require('github-repositories')
const orgs = [
  'ipfs',
  'ipld',
  'libp2p',
  'multiformats'
]

orgs.forEach((org) =>
  githubRepos(org).then(data =>
    data.map((item) => {
      exec('labels -c githubLabels.json ' + item.full_name,
        (error, stdout, stderr) => {
          console.log(`stdout: ${stdout}`)
          console.log(`stderr: ${stderr}`)
          if (error !== null) {
            console.log(`exec error: ${error}`)
          }
        }
      )
    })
  )
)

Any ideas?