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

Fix spawning of Node.js binaries (.cmd files) on Windows #6

Merged
merged 2 commits into from
Apr 2, 2017

Conversation

raleksandar
Copy link
Contributor

This PR fixes running .bat/.cmd files on Windows (and .cmd files are used to wrap Node.js binaries installed via npm and yarn) by setting shell options of child_process.spawn() call on WIndows only.

Fixes #5

@@ -3,7 +3,16 @@ var spawn = require('child_process').spawn;
function Spawn(stream, command, args, name, output) {
var exited = false;
var ended = false;
var spawnedProcess = spawn(command, args);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep spawnedProcess initialized at the top of the method here (keep undefined):

var spawnedProcess;

lib/Spawn.js Outdated
};
}

var spawnedProcess = spawn(command, args, options);
Copy link
Owner

@arjunmehta arjunmehta Apr 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping with above comment remove var:

spawnedProcess = spawn(command, args, options);

Copy link
Owner

@arjunmehta arjunmehta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few nits before approval.

lib/Spawn.js Outdated
if (process.platform === 'win32') {
options = {
// required so that .bat/.cmd files can be spawned
shell: process.env.comspec || 'cmd.exe',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove trailing comma

@raleksandar
Copy link
Contributor Author

Made requested changes. Do you want me to rebase and squash these in a single commit?

@arjunmehta
Copy link
Owner

arjunmehta commented Apr 2, 2017

Looks good! No need to squash. I can do that over here.
I would like to find a way to test on a CI that supports windows. I've been wanting to do this for a while.
That way we can ensure that it works on all versions of node (1-7) on all platforms.

For now let's merge and I'll find a way of testing before publishing a new release.

Thank you for your help!

@arjunmehta arjunmehta merged commit b906ba0 into arjunmehta:master Apr 2, 2017
@raleksandar
Copy link
Contributor Author

Happy to help :)

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

Successfully merging this pull request may close these issues.

Executing batch command (cmd or bat) in windows fails
2 participants