-
-
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)
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 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