mysticatea / npm-run-all

A CLI tool to run multiple npm-scripts in parallel or sequential.
MIT License
5.72k stars 240 forks source link

How to run scripts like "next dev" (Next.js)? #226

Open jasonkylefrank opened 2 years ago

jasonkylefrank commented 2 years ago

Hello!

I'm trying to use this library to run multiple commands in parallel. One of the npm scripts that my package.json currently has is like:

"dev": "next dev"

...where next refers to Next.js and their build scripts. "next" is not an npm script listed in my package.json but it works fine somehow (it gets set up after you start your project via npx create-next-app).

I want to turn the dev npm script into:

"dev": "npm-run-all --parallel firebase-emulate  'next dev'"

...where firebase-emulate refers to another one of my npm scripts and next dev would run Next.js's build scripts as it does when that part is it's own "value" of one of the npm scripts, as shown in the earlier snippet.

As I have it written, this does not work.

Is there a way to use this library to run the dev command that I want without having to make the next dev an explicit npm script? I would rather not have to make the built-in Next.js build scripts their own npm scripts since it would litter-up my npm scripts with dedicated scripts that we would not actually run on an individual basis.

ulisses-cruz commented 2 years ago

I think a way you can make this work, is by doing something like this:

{
    "scripts": {
        "dev": "run-p dev:*",
        "dev:firebase": "firebase-emulate",
        "dev:next": "next dev"
    }
}

now when you use npm run dev it should work.

jasonkylefrank commented 2 years ago

@ulisses-cruz Yes, as I mentioned that would work but the point of my question is to find out if there is a way to do it without having to make an explicit npm script for each such script. 😀