As you can see, each individual command is pretty short and it’s already unclear what the npm script does. Moreover, if the script encounters an error it can be difficult to see which part of it failed.

This makes the function of each script much clearer, and errors are a lot easier to debug as you can see exactly which script failed.

Although if you have a lot of scripts — each with their own pre- and post- hooks — then your package.json could end up looking very messy.

You can use pre- and post- hooks on all npm scripts, just prepend pre or post to the name of your script.

In conclusion, it’s down to you which method you prefer — and it might depend on the service, or even the individual script. Some commands might have no chance of failing and so don’t need to be separated, whereas others might be unimaginably long so need to be separated for clarity.