Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: wait for message on stdout before continuing #43

Closed
poislagarde opened this issue Jun 13, 2016 · 6 comments
Closed

Feature request: wait for message on stdout before continuing #43

poislagarde opened this issue Jun 13, 2016 · 6 comments

Comments

@poislagarde
Copy link

Hey! I'm setting up a node server with TypeScript, and I'd like to spawn tsc -w (compile + watch .ts files) in parallel with nodemon (watch compiled .js files + restart server).
The problem is that I need to delay the spawning of nodemon until tsc is done compiling.

I think it would be very useful if we could tell npm-run-all to wait for a message to appear on stdout before continuing to spawn tasks.

What do you think? If you guys think it's a good idea I can try to put together a PR. Of course I could use some pointers in that case.

@mysticatea
Copy link
Owner

Thank you for this issue.

Hmm, sorry, I don't want to add the feature to wait for specified message.
I think it's too complex for CLI option.

There are some workarounds.

  1. Does the first build before watching.

    {
        "build": "tsc ...",
        "watch": "npm-run-all build -p watch:*",
        "watch:tsc": "tsc -w ...",
        "watch:nodemon": "nodemon ..."
    }
  2. Wait for built files in nodemon command.
    https://stackoverflow.com/questions/37466757/how-do-i-run-postmans-newman-in-ci-environment
    wait-on command can wait for local files.

@poislagarde
Copy link
Author

I understand, it could get a little messy. Thank you for the quick answer and help though, and wait-on works great in my case. Thanks again!

@robario
Copy link
Contributor

robario commented Jun 15, 2016

@mysticatea
I know how @poislagarde feel.

{
    "build": "webpack",
    "watch": "npm-run-all build -p watch:*",
    "watch:webpack": "webpack --watch",
    "watch:depends_on_webpack": "some_processing ./www/bundle.js",
}

In the case of above, webpack's first build runs twice. (And the first build is slower than the continuous build.)
The idea of using wait-on sounds good.

    "watch:depends_on_webpack": "wait-on ./www/bundle.js && some_processing ./www/bundle.js",

However it is not waiting if ./www/bundle.js already exists.
I want to wait for the completion of the process rather than the file creation.

Should I do like this?

    "watch:depends_on_webpack": "rimraf ./www/bundle.js && wait-on ./www/bundle.js && some_processing ./www/bundle.js",

Otherwise wait for the stdout as described in this issue?
However, I think it is difficult that implement to wait for stdout.

@poislagarde
Copy link
Author

@robario if it helps, I ended up doing this:

"scripts": {
    "prebuild": "rimraf _built",
    "build": "tsc",
    "watch": "npm-run-all prebuild -p watch:*",
    "watch:tsc": "tsc -w",
    "watch:nodemon": "wait-on _built/server.js && nodemon _built/server.js --watch _built"
}

wait-on works fine here because the _built directory is cleared (rimraf _built) before.

@robario
Copy link
Contributor

robario commented Jun 20, 2016

@poislagarde
Thank you for telling me the actual situation.
I started using rimraf and wait-on, too.

@mysticatea
Copy link
Owner

Closing as I don't want to add this feature.
Thank you for making request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants