Skip to content

ExecFile

[<Interface>]
type ExecFile =
    abstract member Invoke (file: string, ?args: string array, ?options: ExecFileOptions, ?callback: Callback8) : ChildProcess
    abstract member Invoke (file: string, ?options: ExecFileOptions, ?callback: Callback7) : ChildProcess
    abstract member Invoke (file: string, args: string array option, options: ExecFileOptionsWithStringEncoding, ?callback: Callback6) : ChildProcess
    abstract member Invoke (file: string, options: ExecFileOptionsWithStringEncoding, ?callback: Callback5) : ChildProcess
    abstract member Invoke (file: string, args: string array option, options: ExecFileOptionsWithBufferEncoding, ?callback: Callback4) : ChildProcess
    abstract member Invoke (file: string, options: ExecFileOptionsWithBufferEncoding, ?callback: Callback3) : ChildProcess
    abstract member Invoke (file: string, ?args: string array, ?callback: Callback2) : ChildProcess
    abstract member Invoke (file: string, ?callback: Callback) : ChildProcess
    abstract member __promisify__ (file: string, ?args: string array, ?options: ExecFileOptions) : PromiseWithChild<Item8>
    abstract member __promisify__ (file: string, ?options: ExecFileOptions) : PromiseWithChild<Item7>
    abstract member __promisify__ (file: string, args: string array option, options: ExecFileOptionsWithStringEncoding) : PromiseWithChild<Item6>
    abstract member __promisify__ (file: string, options: ExecFileOptionsWithStringEncoding) : PromiseWithChild<Item5>
    abstract member __promisify__ (file: string, args: string array option, options: ExecFileOptionsWithBufferEncoding) : PromiseWithChild<Item4>
    abstract member __promisify__ (file: string, options: ExecFileOptionsWithBufferEncoding) : PromiseWithChild<Item3>
    abstract member __promisify__ (file: string, ?args: string array) : PromiseWithChild<Item2>
    abstract member __promisify__ (file: string) : PromiseWithChild<Item>
AssemblyXantham.Fable.Node

Declared inside

Callback
Callback2
Callback3
Callback4
Callback5
Callback6
Callback7
Callback8
Promisify

Methods

abstract member Invoke (file: string, ?args: string array, ?options: ExecFileOptions, ?callback: Callback8) : ChildProcess

The child_process.execFile() function is similar to exec except that it does not spawn a shell by default. Rather, the specified executable file is spawned directly as a new process making it slightly more efficient than exec.

The same options as exec are supported. Since a shell is not spawned, behaviors such as I/O redirection and file globbing are not supported.

import { execFile } from 'node:child_process';
const child = execFile('node', ['--version'], (error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});

The stdout and stderr arguments passed to the callback will contain the stdout and stderr output of the child process. By default, Node.js will decode the output as UTF-8 and pass strings to the callback. The encoding option can be used to specify the character encoding used to decode the stdout and stderr output. If encoding is 'buffer', or an unrecognized character encoding, Buffer objects will be passed to the callback instead.

If this method is invoked as its util.promisify() ed version, it returns a Promise for an Object with stdout and stderr properties. The returned ChildProcess instance is attached to the Promise as a child property. In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same error object given in the callback, but with two additional properties stdout and stderr.

import util from 'node:util';
import child_process from 'node:child_process';
const execFile = util.promisify(child_process.execFile);
async function getVersion() {
const { stdout } = await execFile('node', ['--version']);
console.log(stdout);
}
getVersion();

If the shell option is enabled, do not pass unsanitized user input to thisfunction. Any input containing shell metacharacters may be used to triggerarbitrary command execution.

If the signal option is enabled, calling .abort() on the corresponding AbortController is similar to calling .kill() on the child process except the error passed to the callback will be an AbortError:

import { execFile } from 'node:child_process';
const controller = new AbortController();
const { signal } = controller;
const child = execFile('node', ['--version'], { signal }, (error) => {
console.error(error); // an AbortError
});
controller.abort();

@since v0.1.91

Parameter
fileThe name or path of the executable file to run.
argsList of string arguments.
callbackCalled with the output when process terminates.
abstract member Invoke (file: string, ?options: ExecFileOptions, ?callback: Callback7) : ChildProcess

The child_process.execFile() function is similar to exec except that it does not spawn a shell by default. Rather, the specified executable file is spawned directly as a new process making it slightly more efficient than exec.

The same options as exec are supported. Since a shell is not spawned, behaviors such as I/O redirection and file globbing are not supported.

import { execFile } from 'node:child_process';
const child = execFile('node', ['--version'], (error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});

The stdout and stderr arguments passed to the callback will contain the stdout and stderr output of the child process. By default, Node.js will decode the output as UTF-8 and pass strings to the callback. The encoding option can be used to specify the character encoding used to decode the stdout and stderr output. If encoding is 'buffer', or an unrecognized character encoding, Buffer objects will be passed to the callback instead.

If this method is invoked as its util.promisify() ed version, it returns a Promise for an Object with stdout and stderr properties. The returned ChildProcess instance is attached to the Promise as a child property. In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same error object given in the callback, but with two additional properties stdout and stderr.

import util from 'node:util';
import child_process from 'node:child_process';
const execFile = util.promisify(child_process.execFile);
async function getVersion() {
const { stdout } = await execFile('node', ['--version']);
console.log(stdout);
}
getVersion();

If the shell option is enabled, do not pass unsanitized user input to thisfunction. Any input containing shell metacharacters may be used to triggerarbitrary command execution.

If the signal option is enabled, calling .abort() on the corresponding AbortController is similar to calling .kill() on the child process except the error passed to the callback will be an AbortError:

import { execFile } from 'node:child_process';
const controller = new AbortController();
const { signal } = controller;
const child = execFile('node', ['--version'], { signal }, (error) => {
console.error(error); // an AbortError
});
controller.abort();

@since v0.1.91

Parameter
fileThe name or path of the executable file to run.
argsList of string arguments.
callbackCalled with the output when process terminates.
abstract member Invoke (file: string, args: string array option, options: ExecFileOptionsWithStringEncoding, ?callback: Callback6) : ChildProcess

The child_process.execFile() function is similar to exec except that it does not spawn a shell by default. Rather, the specified executable file is spawned directly as a new process making it slightly more efficient than exec.

The same options as exec are supported. Since a shell is not spawned, behaviors such as I/O redirection and file globbing are not supported.

import { execFile } from 'node:child_process';
const child = execFile('node', ['--version'], (error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});

The stdout and stderr arguments passed to the callback will contain the stdout and stderr output of the child process. By default, Node.js will decode the output as UTF-8 and pass strings to the callback. The encoding option can be used to specify the character encoding used to decode the stdout and stderr output. If encoding is 'buffer', or an unrecognized character encoding, Buffer objects will be passed to the callback instead.

If this method is invoked as its util.promisify() ed version, it returns a Promise for an Object with stdout and stderr properties. The returned ChildProcess instance is attached to the Promise as a child property. In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same error object given in the callback, but with two additional properties stdout and stderr.

import util from 'node:util';
import child_process from 'node:child_process';
const execFile = util.promisify(child_process.execFile);
async function getVersion() {
const { stdout } = await execFile('node', ['--version']);
console.log(stdout);
}
getVersion();

If the shell option is enabled, do not pass unsanitized user input to thisfunction. Any input containing shell metacharacters may be used to triggerarbitrary command execution.

If the signal option is enabled, calling .abort() on the corresponding AbortController is similar to calling .kill() on the child process except the error passed to the callback will be an AbortError:

import { execFile } from 'node:child_process';
const controller = new AbortController();
const { signal } = controller;
const child = execFile('node', ['--version'], { signal }, (error) => {
console.error(error); // an AbortError
});
controller.abort();

@since v0.1.91

Parameter
fileThe name or path of the executable file to run.
argsList of string arguments.
callbackCalled with the output when process terminates.
abstract member Invoke (file: string, options: ExecFileOptionsWithStringEncoding, ?callback: Callback5) : ChildProcess

The child_process.execFile() function is similar to exec except that it does not spawn a shell by default. Rather, the specified executable file is spawned directly as a new process making it slightly more efficient than exec.

The same options as exec are supported. Since a shell is not spawned, behaviors such as I/O redirection and file globbing are not supported.

import { execFile } from 'node:child_process';
const child = execFile('node', ['--version'], (error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});

The stdout and stderr arguments passed to the callback will contain the stdout and stderr output of the child process. By default, Node.js will decode the output as UTF-8 and pass strings to the callback. The encoding option can be used to specify the character encoding used to decode the stdout and stderr output. If encoding is 'buffer', or an unrecognized character encoding, Buffer objects will be passed to the callback instead.

If this method is invoked as its util.promisify() ed version, it returns a Promise for an Object with stdout and stderr properties. The returned ChildProcess instance is attached to the Promise as a child property. In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same error object given in the callback, but with two additional properties stdout and stderr.

import util from 'node:util';
import child_process from 'node:child_process';
const execFile = util.promisify(child_process.execFile);
async function getVersion() {
const { stdout } = await execFile('node', ['--version']);
console.log(stdout);
}
getVersion();

If the shell option is enabled, do not pass unsanitized user input to thisfunction. Any input containing shell metacharacters may be used to triggerarbitrary command execution.

If the signal option is enabled, calling .abort() on the corresponding AbortController is similar to calling .kill() on the child process except the error passed to the callback will be an AbortError:

import { execFile } from 'node:child_process';
const controller = new AbortController();
const { signal } = controller;
const child = execFile('node', ['--version'], { signal }, (error) => {
console.error(error); // an AbortError
});
controller.abort();

@since v0.1.91

Parameter
fileThe name or path of the executable file to run.
argsList of string arguments.
callbackCalled with the output when process terminates.
abstract member Invoke (file: string, args: string array option, options: ExecFileOptionsWithBufferEncoding, ?callback: Callback4) : ChildProcess

The child_process.execFile() function is similar to exec except that it does not spawn a shell by default. Rather, the specified executable file is spawned directly as a new process making it slightly more efficient than exec.

The same options as exec are supported. Since a shell is not spawned, behaviors such as I/O redirection and file globbing are not supported.

import { execFile } from 'node:child_process';
const child = execFile('node', ['--version'], (error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});

The stdout and stderr arguments passed to the callback will contain the stdout and stderr output of the child process. By default, Node.js will decode the output as UTF-8 and pass strings to the callback. The encoding option can be used to specify the character encoding used to decode the stdout and stderr output. If encoding is 'buffer', or an unrecognized character encoding, Buffer objects will be passed to the callback instead.

If this method is invoked as its util.promisify() ed version, it returns a Promise for an Object with stdout and stderr properties. The returned ChildProcess instance is attached to the Promise as a child property. In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same error object given in the callback, but with two additional properties stdout and stderr.

import util from 'node:util';
import child_process from 'node:child_process';
const execFile = util.promisify(child_process.execFile);
async function getVersion() {
const { stdout } = await execFile('node', ['--version']);
console.log(stdout);
}
getVersion();

If the shell option is enabled, do not pass unsanitized user input to thisfunction. Any input containing shell metacharacters may be used to triggerarbitrary command execution.

If the signal option is enabled, calling .abort() on the corresponding AbortController is similar to calling .kill() on the child process except the error passed to the callback will be an AbortError:

import { execFile } from 'node:child_process';
const controller = new AbortController();
const { signal } = controller;
const child = execFile('node', ['--version'], { signal }, (error) => {
console.error(error); // an AbortError
});
controller.abort();

@since v0.1.91

Parameter
fileThe name or path of the executable file to run.
argsList of string arguments.
callbackCalled with the output when process terminates.
abstract member Invoke (file: string, options: ExecFileOptionsWithBufferEncoding, ?callback: Callback3) : ChildProcess

The child_process.execFile() function is similar to exec except that it does not spawn a shell by default. Rather, the specified executable file is spawned directly as a new process making it slightly more efficient than exec.

The same options as exec are supported. Since a shell is not spawned, behaviors such as I/O redirection and file globbing are not supported.

import { execFile } from 'node:child_process';
const child = execFile('node', ['--version'], (error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});

The stdout and stderr arguments passed to the callback will contain the stdout and stderr output of the child process. By default, Node.js will decode the output as UTF-8 and pass strings to the callback. The encoding option can be used to specify the character encoding used to decode the stdout and stderr output. If encoding is 'buffer', or an unrecognized character encoding, Buffer objects will be passed to the callback instead.

If this method is invoked as its util.promisify() ed version, it returns a Promise for an Object with stdout and stderr properties. The returned ChildProcess instance is attached to the Promise as a child property. In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same error object given in the callback, but with two additional properties stdout and stderr.

import util from 'node:util';
import child_process from 'node:child_process';
const execFile = util.promisify(child_process.execFile);
async function getVersion() {
const { stdout } = await execFile('node', ['--version']);
console.log(stdout);
}
getVersion();

If the shell option is enabled, do not pass unsanitized user input to thisfunction. Any input containing shell metacharacters may be used to triggerarbitrary command execution.

If the signal option is enabled, calling .abort() on the corresponding AbortController is similar to calling .kill() on the child process except the error passed to the callback will be an AbortError:

import { execFile } from 'node:child_process';
const controller = new AbortController();
const { signal } = controller;
const child = execFile('node', ['--version'], { signal }, (error) => {
console.error(error); // an AbortError
});
controller.abort();

@since v0.1.91

Parameter
fileThe name or path of the executable file to run.
argsList of string arguments.
callbackCalled with the output when process terminates.
abstract member Invoke (file: string, ?args: string array, ?callback: Callback2) : ChildProcess

The child_process.execFile() function is similar to exec except that it does not spawn a shell by default. Rather, the specified executable file is spawned directly as a new process making it slightly more efficient than exec.

The same options as exec are supported. Since a shell is not spawned, behaviors such as I/O redirection and file globbing are not supported.

import { execFile } from 'node:child_process';
const child = execFile('node', ['--version'], (error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});

The stdout and stderr arguments passed to the callback will contain the stdout and stderr output of the child process. By default, Node.js will decode the output as UTF-8 and pass strings to the callback. The encoding option can be used to specify the character encoding used to decode the stdout and stderr output. If encoding is 'buffer', or an unrecognized character encoding, Buffer objects will be passed to the callback instead.

If this method is invoked as its util.promisify() ed version, it returns a Promise for an Object with stdout and stderr properties. The returned ChildProcess instance is attached to the Promise as a child property. In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same error object given in the callback, but with two additional properties stdout and stderr.

import util from 'node:util';
import child_process from 'node:child_process';
const execFile = util.promisify(child_process.execFile);
async function getVersion() {
const { stdout } = await execFile('node', ['--version']);
console.log(stdout);
}
getVersion();

If the shell option is enabled, do not pass unsanitized user input to thisfunction. Any input containing shell metacharacters may be used to triggerarbitrary command execution.

If the signal option is enabled, calling .abort() on the corresponding AbortController is similar to calling .kill() on the child process except the error passed to the callback will be an AbortError:

import { execFile } from 'node:child_process';
const controller = new AbortController();
const { signal } = controller;
const child = execFile('node', ['--version'], { signal }, (error) => {
console.error(error); // an AbortError
});
controller.abort();

@since v0.1.91

Parameter
fileThe name or path of the executable file to run.
argsList of string arguments.
callbackCalled with the output when process terminates.
abstract member Invoke (file: string, ?callback: Callback) : ChildProcess

The child_process.execFile() function is similar to exec except that it does not spawn a shell by default. Rather, the specified executable file is spawned directly as a new process making it slightly more efficient than exec.

The same options as exec are supported. Since a shell is not spawned, behaviors such as I/O redirection and file globbing are not supported.

import { execFile } from 'node:child_process';
const child = execFile('node', ['--version'], (error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});

The stdout and stderr arguments passed to the callback will contain the stdout and stderr output of the child process. By default, Node.js will decode the output as UTF-8 and pass strings to the callback. The encoding option can be used to specify the character encoding used to decode the stdout and stderr output. If encoding is 'buffer', or an unrecognized character encoding, Buffer objects will be passed to the callback instead.

If this method is invoked as its util.promisify() ed version, it returns a Promise for an Object with stdout and stderr properties. The returned ChildProcess instance is attached to the Promise as a child property. In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same error object given in the callback, but with two additional properties stdout and stderr.

import util from 'node:util';
import child_process from 'node:child_process';
const execFile = util.promisify(child_process.execFile);
async function getVersion() {
const { stdout } = await execFile('node', ['--version']);
console.log(stdout);
}
getVersion();

If the shell option is enabled, do not pass unsanitized user input to thisfunction. Any input containing shell metacharacters may be used to triggerarbitrary command execution.

If the signal option is enabled, calling .abort() on the corresponding AbortController is similar to calling .kill() on the child process except the error passed to the callback will be an AbortError:

import { execFile } from 'node:child_process';
const controller = new AbortController();
const { signal } = controller;
const child = execFile('node', ['--version'], { signal }, (error) => {
console.error(error); // an AbortError
});
controller.abort();

@since v0.1.91

Parameter
fileThe name or path of the executable file to run.
argsList of string arguments.
callbackCalled with the output when process terminates.
abstract member __promisify__ (file: string, ?args: string array, ?options: ExecFileOptions) : PromiseWithChild<Item8>
abstract member __promisify__ (file: string, ?options: ExecFileOptions) : PromiseWithChild<Item7>
abstract member __promisify__ (file: string, args: string array option, options: ExecFileOptionsWithStringEncoding) : PromiseWithChild<Item6>
abstract member __promisify__ (file: string, options: ExecFileOptionsWithStringEncoding) : PromiseWithChild<Item5>
abstract member __promisify__ (file: string, args: string array option, options: ExecFileOptionsWithBufferEncoding) : PromiseWithChild<Item4>
abstract member __promisify__ (file: string, options: ExecFileOptionsWithBufferEncoding) : PromiseWithChild<Item3>
abstract member __promisify__ (file: string, ?args: string array) : PromiseWithChild<Item2>
abstract member __promisify__ (file: string) : PromiseWithChild<Item>