Skip to content

Instantly share code, notes, and snippets.

@ff6347
Forked from romanlab/script.js
Last active March 15, 2019 05:45
Show Gist options
  • Save ff6347/b13fdedf25bb85f241a4a250e456be5f to your computer and use it in GitHub Desktop.
Save ff6347/b13fdedf25bb85f241a4a250e456be5f to your computer and use it in GitHub Desktop.
basic node js script for github actions (great pattern to check if we are a module or cli)
const program = require('commander')
const fs = require('fs')
async function doSomething(arg) { return arg }
async function main() {
const event = JSON.parse(fs.readFileSync('/github/workflow/event.json', 'utf8'))
const firstArg = program.firstArg
const result = await doSometing(firstArg)
return result
}
if (require.main === module) {
program
.option('-f, --firstArg <argParam>', 'The list of valid licenses')
.parse(process.argv)
main()
.then(res => {
console.log({ res })
process.exitCode = 0
})
.catch(err => {
console.log({ err })
process.exitCode = 1
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment