@@ -175,7 +175,7 @@ replace the existing process and uses a shell to execute the command.*
175
175
176
176
### child_process.execFile(file[ , args] [ , options ] [ , callback] )
177
177
178
- * ` file ` {String} The filename of the program to run
178
+ * ` file ` {String} A path to an executable file
179
179
* ` args ` {Array} List of string arguments
180
180
* ` options ` {Object}
181
181
* ` cwd ` {String} Current working directory of the child process
@@ -193,20 +193,20 @@ replace the existing process and uses a shell to execute the command.*
193
193
* ` stderr ` {Buffer}
194
194
* Return: ChildProcess object
195
195
196
- The ` child_process.execFile() ` method is similar to [ ` child_process.exec() ` ] [ ]
197
- except that it does not first spawn a shell. Rather, the specified ` command ` is
198
- spawned directly as a new process making it slightly more efficient than
199
- [ ` child_process.exec() ` ] [ ] . The same options are support by both
200
- ` child_process.exec() ` and ` child_process.execFile() ` .
196
+ The ` child_process.execFile() ` function is similar to [ ` child_process.exec() ` ] [ ]
197
+ except that it does not spawn a shell. Rather, the specified executable ` file `
198
+ is spawned directly as a new process making it slightly more efficient than
199
+ [ ` child_process.exec() ` ] [ ] .
201
200
202
- const exec = require('child_process').execFile;
203
- const child = execFile('cat *.js bad_file | wc -l',
204
- (error, stdout, stderr) => {
205
- console.log(`stdout: ${stdout}`);
206
- console.log(`stderr: ${stderr}`);
207
- if (error !== null) {
208
- console.log(`exec error: ${error}`);
209
- }
201
+ The same options as ` child_process.exec() ` are supported. Since a shell is not
202
+ spawned, behaviors such as I/O redirection and file globbing are not supported.
203
+
204
+ const execFile = require('child_process').execFile;
205
+ const child = execFile('node', ['--version'], (error, stdout, stderr) => {
206
+ if (error) {
207
+ throw error;
208
+ }
209
+ console.log(stdout);
210
210
});
211
211
212
212
### child_process.fork(modulePath[ , args] [ , options ] )
0 commit comments