Automatically run scripts with NPM/Yarn before or after another script.
If you want to run a script before another one completes, you can do this by prepending
pre to the script name. NPM (or Yarn) will automatically run the script.
Suppose I have a script called
test that runs my test suite. But before I do that, I want to make sure a script called
build runs first. I could have a configuration like this:
Now when I run this command:
npm run test
pretest script will automatically be run first, and in the example above, that means the
build script automatically runs before the
post as the prefix to run a script after another script.