mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
Merge pull request #34034 from TheDSCPL/master
Added the definition file for the 'child-process-promise' package
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import * as cpp from "child-process-promise";
|
||||
|
||||
import {
|
||||
ChildProcess
|
||||
} from 'child_process';
|
||||
|
||||
const a = cpp.exec("echo \"Hello world!\"");
|
||||
a.childProcess; // $ExpectType ChildProcess
|
||||
|
||||
(async () => {
|
||||
const at = await a;
|
||||
at.childProcess; // $ExpectType ChildProcess
|
||||
at.stdout; // $ExpectType string
|
||||
at.stderr; // $ExpectType string
|
||||
})();
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
// Type definitions for child-process-promise 2.2
|
||||
// Project: https://github.com/patrick-steele-idem/child-process-promise
|
||||
// Definitions by: Luis Paulo <https://github.com/TheDSCPL>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import {
|
||||
ChildProcess,
|
||||
ExecFileOptionsWithBufferEncoding, ExecFileOptionsWithOtherEncoding,
|
||||
ExecFileOptionsWithStringEncoding,
|
||||
ExecOptions,
|
||||
ForkOptions,
|
||||
SpawnOptions
|
||||
} from 'child_process';
|
||||
|
||||
/**
|
||||
* Simple wrapper around the child_process module that makes use of promises
|
||||
*/
|
||||
|
||||
export interface PromiseResult<Enc extends string|Buffer> {
|
||||
childProcess: ChildProcess;
|
||||
stdout: Enc;
|
||||
stderr: Enc;
|
||||
}
|
||||
|
||||
export interface SpawnPromiseResult extends PromiseResult<string> {
|
||||
code: number;
|
||||
}
|
||||
|
||||
export interface ChildProcessPromise<T> extends Promise<T> {
|
||||
childProcess: ChildProcess;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
* Pass an additional capture option to buffer the result of stdout and/or stderr
|
||||
* Default: []
|
||||
*/
|
||||
capture?: []|['stdout']|['stderr']|['stdout'|'stderr']|['stderr'|'stdout'];
|
||||
/**
|
||||
* Array of the numbers that should be interpreted as successful execution codes
|
||||
* Default: [0]
|
||||
*/
|
||||
successfulExitCodes?: number[];
|
||||
}
|
||||
|
||||
export function exec(
|
||||
command: Readonly<string>,
|
||||
options: Readonly<Options & { encoding: "buffer" | null } & ExecOptions>
|
||||
): ChildProcessPromise<PromiseResult<Buffer>>;
|
||||
export function exec(
|
||||
command: Readonly<string>,
|
||||
options: Readonly<Options & { encoding?: BufferEncoding } & ExecOptions>
|
||||
): ChildProcessPromise<PromiseResult<string>>;
|
||||
export function exec(
|
||||
command: Readonly<string>,
|
||||
options: Readonly<Options & { encoding?: string } & ExecOptions>
|
||||
): ChildProcessPromise<PromiseResult<string | Buffer>>;
|
||||
export function exec(
|
||||
command: Readonly<string>,
|
||||
options?: Readonly<Options & ExecOptions>
|
||||
): ChildProcessPromise<PromiseResult<string>>;
|
||||
|
||||
export function execFile(
|
||||
file: Readonly<string>,
|
||||
options: Readonly<Options & ExecFileOptionsWithBufferEncoding>
|
||||
): ChildProcessPromise<PromiseResult<Buffer>>;
|
||||
export function execFile(
|
||||
file: Readonly<string>,
|
||||
args: ReadonlyArray<string> | null,
|
||||
options: Readonly<Options & ExecFileOptionsWithBufferEncoding>
|
||||
): ChildProcessPromise<PromiseResult<Buffer>>;
|
||||
export function execFile(
|
||||
file: Readonly<string>,
|
||||
options: Readonly<Options & ExecFileOptionsWithStringEncoding>
|
||||
): ChildProcessPromise<PromiseResult<string>>;
|
||||
export function execFile(
|
||||
file: Readonly<string>,
|
||||
options: Readonly<Options & ExecFileOptionsWithOtherEncoding>
|
||||
): ChildProcessPromise<PromiseResult<string | Buffer>>;
|
||||
export function execFile(
|
||||
file: Readonly<string>,
|
||||
args: ReadonlyArray<string> | null,
|
||||
options: Readonly<Options & ExecFileOptionsWithOtherEncoding>
|
||||
): ChildProcessPromise<PromiseResult<string | Buffer>>;
|
||||
export function execFile(
|
||||
file: Readonly<string>,
|
||||
args?: ReadonlyArray<string> | null,
|
||||
options?: Readonly<Options & ExecFileOptionsWithStringEncoding>
|
||||
): ChildProcessPromise<PromiseResult<string>>;
|
||||
|
||||
export function spawn(
|
||||
command: Readonly<string>,
|
||||
args?: ReadonlyArray<string> | null,
|
||||
options?: Readonly<Options & SpawnOptions>
|
||||
): ChildProcessPromise<SpawnPromiseResult>;
|
||||
|
||||
export function fork(
|
||||
modulePath: string,
|
||||
args?: ReadonlyArray<string>,
|
||||
options?: Readonly<Options & ForkOptions>
|
||||
): ChildProcessPromise<SpawnPromiseResult>;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"child-process-promise-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user