Skip to content

Cannot run multiple tasks that use npm-run-all #24

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

Closed
lostm1nd opened this issue Mar 2, 2016 · 13 comments
Closed

Cannot run multiple tasks that use npm-run-all #24

lostm1nd opened this issue Mar 2, 2016 · 13 comments

Comments

@lostm1nd
Copy link

lostm1nd commented Mar 2, 2016

Hello,

I am trying to slim down my build script with npm-run-all. What I really want to use is the pattern matching for running tasks which saves a lot of repeating npm runs.

The thing I am having trouble with is the following scenario:

"copy": "npm-run-all copy:*",
  "copy:images": "copyfiles -u 1 app/images/**/*.* build",
  "copy:fonts": "copyfiles -u 1 app/fonts/**/*.* build",
"lint": "eslint app/scripts/**/*.js",
"browserify": "browserify app/scripts/main.js -o build/scripts/bundle.js  -d -t [ babelify ] -p [minifyify ]",
"build": "npm-run-all copy build:*",
  "build:styles": "pleeease-compile",
  "build:scripts": "npm-run-all lint browserify"

When I run 'npm run copy' everything works okay but trying to run 'npm run build' and the execution hangs on the copy task.

@mysticatea
Copy link
Owner

Thank you for this issue.

Hmm, I have never seen hanging problems caused by nested npm-run-all command.
Could you share a repo to reproduce it?
I'd like to investigate this.

@lostm1nd
Copy link
Author

lostm1nd commented Mar 3, 2016

Thanks for the fast reply.

You can check out this issue in the following app - https://github.com/lostm1nd/WebDevolopment/tree/master/Pizzeria-ES2015

@mysticatea
Copy link
Owner

Thank you!

Hmm, but I cannot reproduce it on my PC.
Could you tell me your environment?

This is mine:

  • Windows 7 64bit
  • Node v4.3.0
  • npm v3.7.5
  • npm-run-all v1.5.1
  • copyfiles v0.2.1

test2

@lostm1nd
Copy link
Author

lostm1nd commented Mar 4, 2016

Mine is:

  • Windows 7 64bit
  • Node v5.4.1
  • NPM v3.8.0 (just upgraded from v3.3.12 and still the same issue)
  • npm-run-all and copyfiles are the same as you listed

Edit:
I just tested it in the cmd.exe and it works. I guess the problem is with git bash since I run most of my commands from there when I am working on a repo. I guess you can close this issue if you wish.

Thanks,

@mysticatea
Copy link
Owner

Okey, I can reproduce it on MINGW64!

@mysticatea
Copy link
Owner

Hmmm, it's very strange.

// ...
console.log("main 1")
let stdin;
try { stdin = process.stdin; } finally { console.log("main 1.5") }
console.log("main 2")
// ...

process.stdin getter stops the program.
console wrote "main 1" then stops.
I never see "main 1.5" and "main 2".

@mysticatea
Copy link
Owner

I typed Enter key once while the program is stopping, then it continues.... 😕

@lostm1nd
Copy link
Author

lostm1nd commented Mar 6, 2016

These three lines of code work for me as expected. It does not hang:

node index.js
1
1.5
2  

Edit: Just updated node to v5.7.1 and the code works again.

@mysticatea
Copy link
Owner

Ah, sorry, I talked about this line.
When npm-run-all hangs, process.stdin seems to never return (then, it will return after I typed Enter key).
I'm still investigating...

@mysticatea
Copy link
Owner

This is a small repro code.

I execute the following command on Git Bash for Windows, then the program will stop at process.stdin of "child".

$ cmd /C="node test.js"
// test.js
"use strict";

const name = process.argv[2] || "parent";

console.log("before stdin:", name);
process.stdin;
console.log("after stdin:", name);

if (process.argv[2] !== "child") {
    require("child_process").spawn(
        process.argv[0],
        [process.argv[1], "child"],
        {stdio: "inherit"}
    );
}

@mysticatea
Copy link
Owner

I reported an issue: nodejs/node#5620

Also, I got the idea of a workaround.
I'm writing it....

@mysticatea
Copy link
Owner

Done.

@lostm1nd Thank you for your help!

@lostm1nd
Copy link
Author

@mysticatea Thank you for the time invested in the issue!

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

2 participants