I wanted an easy process for publishing changes to my simple node module.
My learning…about using npm scripts for build automation
My requirements were very common:
- Failing tests to prevent publishing.
- The lib to be compiled to only when tests pass.
- Simple version management and releases to get tagged in the git repo.
- Avoiding Gulp as its overkill for my simple workflow (so far!).
- Avoid custom shell scripts and be platform independent.
So I’ve learned about some of the great features available in the node scripts entry:
- pre and post triggers
- version bumping
I added these scripts for automation to my simple node module:
Which means I can do a patch version bump, test, publish to npm and tag the release in GitHub with:
and get this output:
Whilst learning this I came across some great resources on automation:
- Nice - albeit old - post from Keith Cirkel on the topic of Npm as a build tool
- Contains a good debate about npm scripts vs Gulp tasks
- Lin Clark’s github-pages-deploy and the related npm blog post is a good read.
- This covers some discussion of shebangs