srun
)
node-step-runner (define atomic steps, then build scripts with them. a global context object between steps is included for you!
mind you, this runner is pretty opinionated
Why not grunt?
grunt is hella confusing
Usage
CLI usage
run scripts with:
srun --script=<scriptname> [--verbose] # e.g. srun --script=postpublish # runs ./scripts/postpublish.js
steps
steps are individual actions of a script and go in ./lib/steps
.
moduleexports = // the pretty/formatted name of the step, only used for display name: 'Hello Step' // a description of your step, used to help clients understand // what it does and its sideeffects description: 'Says hello' options: // define options here so people don't have to look through // your code to find them. `step-runner` will handle extracting // and validating the presence of all the options 'name': 'Name to say hello to' // the action function is given an options parameter and a callback { // use the options defined above (given a client has provided them) // form the `opt` parameter console; ; }
Scripts
scripts go in ./scripts
and call steps with ./lib/step-runner.js
.
var StepRunner = ; module { var stepRunner = verbose: thisverbose ; // you could alternately use promises to control flow stepRunner;}
Global context
when a step runs, it gets a context of this[stepName]
, where this
is the context of the step-runner
callbacks and stepName
is the name of the step based on the filename. thus, you can set values onto the context and access them in your script to configure later steps:
// ./lib/steps/number-maker.jsmoduleexports = name: 'Number Maker' description: 'Adds a random number to the context' options: {} { // setting `this[something]` in a step will make it available in your script later thisnumber = Math * 1000; }
then:
stepRunner;
npm postpublish
Using with i made this with the mindset of easily importing my postpublish
script into my package.json
file:
npm install srun --save-dev
add to package.json
...
"scripts": {
"postpublish": "./node_modules/.bin/srun --script=postpublish"
}
...
every time your npm publish
your module, the patch number will increment by one and you will get a git commit notifying of the release. neato!