Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Use 'which' on cmd before spawn to avoid erros on Windows #1

Merged
merged 1 commit into from about 1 year ago

2 participants

Zeno Rocha James Brumond
Zeno Rocha

Using Command on Windows leads to the message:

CreateProcessW: The system cannot find the file specified.

It happens because of child_process().spawn. But it can be fixed by using which.

See gruntjs/grunt#156

James Brumond kbjr merged commit f779f4f into from April 11, 2013
James Brumond kbjr closed this April 11, 2013
Zeno Rocha

Is there a new version available with this fix?

James Brumond
Owner
kbjr commented April 11, 2013

No, I haven't republished it yet. I will publish a version 0.0.4 later today.

Zeno Rocha

Ok, let me know. We're working hard on yogi alloy and it uses command :)

James Brumond
Owner
kbjr commented April 12, 2013

I just published version 0.0.4

Zeno Rocha

I see but there's an error on that #2

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

Showing 1 unique commit by 1 author.

Apr 08, 2013
Zeno Rocha Use 'which' on cmd before spawn to avoid erros on Windows 382b1d1
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 15 additions and 13 deletions. Show diff stats Hide diff stats

  1. 25  lib/index.js
  2. 3  package.json
25  lib/index.js
@@ -3,6 +3,7 @@ var path    = require('path');
3 3
 var events  = require('events');
4 4
 var cp      = require('child_process');
5 5
 var merge   = require('merge-recursive');
  6
+var which   = require('which').sync;
6 7
 
7 8
 exports.open = function(dir) {
8 9
 	return new CommandRunner(dir);
@@ -17,11 +18,11 @@ exports.writeTo = function(stream) {
17 18
 var CommandRunner = exports.CommandRunner = function(dir, env) {
18 19
 	this.cwd = dir || process.cwd();
19 20
 	this.env = env || process.env;
20  
-	
  21
+
21 22
 	this.queue = [ ];
22 23
 	this.running = false;
23 24
 	this.stopped = false;  // TODO
24  
-	
  25
+
25 26
 	this.lastResult = null;
26 27
 };
27 28
 
@@ -65,12 +66,12 @@ CommandRunner.prototype._next = function() {
65 66
 
66 67
 CommandRunner.prototype._run = function(action, callback) {
67 68
 	callback = async(callback);
68  
-	
  69
+
69 70
 	var done = function() {
70 71
 		this.running = false;
71 72
 		callback();
72 73
 	}.bind(this);
73  
-	
  74
+
74 75
 	switch (action.type) {
75 76
 		// Run a callback
76 77
 		case 'callback':
@@ -84,13 +85,13 @@ CommandRunner.prototype._run = function(action, callback) {
84 85
 				done();
85 86
 			}
86 87
 		break;
87  
-		
  88
+
88 89
 		// Change the current working directory
89 90
 		case 'chdir':
90 91
 			this.dir = path.resolve(this.dir, action.dir);
91 92
 			done();
92 93
 		break;
93  
-		
  94
+
94 95
 		// Run a proc.spawn
95 96
 		case 'exec':
96 97
 			action.opts = merge.recursive(
@@ -98,27 +99,27 @@ CommandRunner.prototype._run = function(action, callback) {
98 99
 				{env: this.env, cwd: this.cwd},
99 100
 				action.opts || { }
100 101
 			);
101  
-			
102  
-			var proc = cp.spawn(action.cmd, action.args || [ ], action.opts);
103  
-			
  102
+
  103
+			var proc = cp.spawn(which(action.cmd), action.args || [ ], action.opts);
  104
+
104 105
 			this.lastPid = proc.pid;
105 106
 
106 107
 			var output = '';
107 108
 			var stdout = '';
108 109
 			var stderr = '';
109  
-			
  110
+
110 111
 			proc.stdout.on('data', function(data) {
111 112
 				stdout += String(data);
112 113
 				output += String(data);
113 114
 				this.emit('stdout', data);
114 115
 			}.bind(this));
115  
-			
  116
+
116 117
 			proc.stderr.on('data', function(data) {
117 118
 				stderr += String(data);
118 119
 				output += String(data);
119 120
 				this.emit('stderr', data);
120 121
 			}.bind(this));
121  
-			
  122
+
122 123
 			proc.on('exit', function(code) {
123 124
 				this.lastOutput = {
124 125
 					stdout: stdout,
3  package.json
@@ -20,6 +20,7 @@
20 20
   "author": "James Brumond",
21 21
   "license": "MIT",
22 22
   "dependencies": {
23  
-    "merge-recursive": "0.0.3"
  23
+    "merge-recursive": "0.0.3",
  24
+    "which": "1.5.0"
24 25
   }
25 26
 }
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.