@j-o-r/sh
Version:
Execute shell commands on Linux-based systems from javascript
97 lines (96 loc) • 2.84 kB
TypeScript
export default SHDispatch;
export type SpawnSyncResponse = {
/**
* - The exit code of the child process. A value of `0` indicates success.
*/
status: number;
/**
* - The signal used to terminate the process, if any.
*/
signal: Buffer | null;
/**
* - An array containing the standard output and standard error of the child process.
*/
output: Array<string | null>;
/**
* - The process ID of the child process.
*/
pid: number;
/**
* - The standard output of the child process.
*/
stdout: Buffer | null;
/**
* - The standard error of the child process.
*/
stderr: Buffer | null;
};
export type SHOptions = {
/**
* - Current working directory of the child process.
*/
cwd?: string | undefined;
/**
* - Environment key-value pairs.
*/
env?: Object | undefined;
/**
* - Explicitly set the value of `argv[0]` sent to the child process.
*/
argv0?: string | any[] | undefined;
/**
* - If true, the child will be a process group leader.
*/
detached?: boolean | undefined;
/**
* - Sets the user identity of the process.
*/
uid?: number | undefined;
/**
* - Sets the group identity of the process.
*/
gid?: number | undefined;
/**
* - Child's stdio configuration.
*/
stdio?: number | "pipe" | "ignore" | "inherit" | StdioOption[] | undefined;
/**
* - If true, runs command inside a shell.
*/
shell?: string | boolean | undefined;
/**
* - In milliseconds, specifies when to terminate the child process.
*/
timeout?: number | undefined;
/**
* - The input to write to stdin.
*/
input?: string | Buffer<ArrayBufferLike> | URL | undefined;
};
export type StdioOption = ("pipe" | "ignore" | "inherit" | number);
export type StdioOptions = Array<StdioOption> | StdioOption;
declare class SHDispatch {
/**
* @param {string} cmd - cmd to execute
*/
constructor(cmd: string);
/**
* @param {import('child_process').SpawnOptions | import('child_process').SpawnSyncOptions} options
* @param {string} [prefix] - command prefix e.g (default) '/usr/bin/env'
* @returns {SHDispatch}
*/
options(options: import("child_process").SpawnOptions | import("child_process").SpawnSyncOptions, prefix?: string): SHDispatch;
/**
* @param {string} [payload]
* @returns {Promise<string>}
*/
run(payload?: string): Promise<string>;
/**
* Works for terminal screen takeovers like editors
* @param {string} [payload]
* @returns {import('child_process').SpawnSyncReturns}
*/
runSync(payload?: string): import("child_process").SpawnSyncReturns<any>;
kill(signal?: string): Promise<number[]>;
#private;
}