3

Consider the following example package.json fragment:

{
   // ...
   "scripts": {
       "start": "npm run b -- --watch",
       "build": "builder --in src --out dest"
   }
   // ...
}

In this, I run build from start, and give it an extra flag. The problem with this approach is it actually creates another instance of the NPM run. It works, but it's ugly.

Is there a clean way to reference the build command from the start command without having to make another call to NPM?

1 Answer 1

1

Is there a clean way to reference the build command from the start command without having to make another call to NPM?

Not really.

If you just don't like npm's verbose output, you can silence that with npm run b -s -- --watch.

If you are calling multiple npm scripts from one parent script, you may want to look into an npm task runner. Here is a list of a few: https://github.com/RyanZim/awesome-npm-scripts#task-runners. (Disclaimer: awesome-npm-scripts is my personal project)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.