Published on

Cross Platform NPM Scripts with shx and npm run all

Authors

In the process of trying to understand how Lerna is used I looked at some big repos that exist in the wild and also came across 2 interesting NPM packages:

  • shx: This lets you run Unix like commands in your package.json scripts section. Using shx makes these scripts work cross-platform not just in Un/Linux environments.
  • npm-run-all: Instead of having to chain commands together using && in your package.json scripts you can instead use this package which lets you simply specify the commands one after another.
    • npm run script1 && npm run script2 && num run script3 becomes run-s script1 script2 script3 or simply run-s script*. This runs these scripts sequentially.
      • You can also run these in parallel by using run-p script1 script2 script3 or simply run-p script*.