sindresorhus / grunt-shell

Run shell commands
MIT License
949 stars 126 forks source link

Git-command stuck #95

Closed Jpunt closed 8 years ago

Jpunt commented 9 years ago

My shell gets stuck when running this command, but only sometimes:

commitVersion: {
  command: "git commit -am 'Release version <%= new_version %>' && git tag <%= new_version %> && git push && git push --tags",
},

new_version comes from task from grunt-prompt. The weird thing is, the commands are actually executed (i've got a new commit with that message, a new tag, and everything is pushed), but my shell doesn't get the callback:

Running "prompt:release" (prompt) task
? Current version is 1.0.13, what version do you wanna release? 1.0.14

Running "replace:version" (replace) task

Running "shell:commitVersion" (shell) task

What can I try to fix this?

derpoho commented 9 years ago

Same here.

Our Command executes git flow feature start "feature_name" and gets stuck although everything is done correctly.

Any fix?

derpoho commented 9 years ago

@Jpunt After a quick test i suggest you to use grunt-exec in the meantime until this is fixed. It works for us and the commands are the same.

silverwind commented 9 years ago

Also had a command getting stuck: ncu -u which is npm-check-updates.

silverwind commented 9 years ago

Nevermind me, my issue seems with the module itself - https://github.com/tjunnone/npm-check-updates/issues/119

zenopopovici commented 9 years ago

Nope, it's a grunt-shell issue. Also npm install breaks. This could be the reason: https://github.com/tjunnone/npm-check-updates/issues/119

silverwind commented 9 years ago

I think the issue with ncu boils down to process.stdin.isTTY being undefined in processes spawned by exec, making is-stdin think there i something on stdin when there is not. grunt-shell's attempt to pipe stdin (process.stdin.pipe(cp.stdin)) to the child is fruitless because the exec command already has run by the point this pipe is attached.

I think the proper solution here would be to switch to spawn and define stdio stream handling inside the spawn options. Either that, or it's a node bug with isTTY (though undefined vs false doesn't change much for this bug).

sindresorhus commented 8 years ago

Closing as it seems it's a Node.js core problem and nothing we can do here.

silverwind commented 7 years ago

I think this should be fixed in this module or maybe a wrapper by calling stdin.end() on the ChildProcess. Any child process that waits on stdin will hang until stdin is explicitely closed:

https://nodejs.org/api/child_process.html#child_process_child_stdin