From 0229272d2c2503197792bd89104d5d9455edc9d3 Mon Sep 17 00:00:00 2001 From: Luis Paulo Date: Tue, 19 Mar 2019 16:43:44 +0000 Subject: [PATCH 1/8] Added the definition file for the 'child-process-promise' package --- .../child-process-promise-tests.ts | 15 +++ types/child-process-promise/index.d.ts | 113 ++++++++++++++++++ types/child-process-promise/tsconfig.json | 22 ++++ types/child-process-promise/tslint.json | 1 + 4 files changed, 151 insertions(+) create mode 100644 types/child-process-promise/child-process-promise-tests.ts create mode 100644 types/child-process-promise/index.d.ts create mode 100644 types/child-process-promise/tsconfig.json create mode 100644 types/child-process-promise/tslint.json diff --git a/types/child-process-promise/child-process-promise-tests.ts b/types/child-process-promise/child-process-promise-tests.ts new file mode 100644 index 0000000000..c76f0c9a49 --- /dev/null +++ b/types/child-process-promise/child-process-promise-tests.ts @@ -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 +})(); \ No newline at end of file diff --git a/types/child-process-promise/index.d.ts b/types/child-process-promise/index.d.ts new file mode 100644 index 0000000000..2740c8e197 --- /dev/null +++ b/types/child-process-promise/index.d.ts @@ -0,0 +1,113 @@ +// Type definitions for child-process-promise 2.2.1 +// Project: https://github.com/TheDSCPL/types_child-process-promise +// Definitions by: Luis Paulo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.3.3 + +/// + +// import child_process = require('child_process'); +import { + ChildProcess, + ExecFileOptionsWithBufferEncoding, ExecFileOptionsWithOtherEncoding, + ExecFileOptionsWithStringEncoding, + ExecOptions, + ForkOptions, + SpawnOptions +} from 'child_process'; + +export = cpp; +export as namespace cpp; + +/** + * Simple wrapper around the child_process module that makes use of promises + */ +declare namespace cpp { + interface PromiseResult { + childProcess: ChildProcess, + stdout: Enc, + stderr: Enc + } + + interface SpawnPromiseResult extends PromiseResult { + code: number + } + + interface ChildProcessPromise extends Promise { + 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, + options: Readonly + ): ChildProcessPromise>; + export function exec( + command: Readonly, + options: Readonly + ): ChildProcessPromise>; + export function exec( + command: Readonly, + options: Readonly + ): ChildProcessPromise>; + export function exec( + command: Readonly, + options?: Readonly + ): ChildProcessPromise>; + + export function execFile( + file: Readonly, + options: Readonly + ): ChildProcessPromise>; + export function execFile( + file: Readonly, + args: ReadonlyArray | null, + options: Readonly + ): ChildProcessPromise>; + export function execFile( + file: Readonly, + options: Readonly + ): ChildProcessPromise>; + export function execFile( + file: Readonly, + args: ReadonlyArray | null, + options: Readonly + ): ChildProcessPromise>; + export function execFile( + file: Readonly, + options: Readonly + ): ChildProcessPromise>; + export function execFile( + file: Readonly, + args: ReadonlyArray | null, + options: Readonly + ): ChildProcessPromise>; + export function execFile( + file: Readonly, + args?: ReadonlyArray | null + ): ChildProcessPromise>; + + export function spawn( + command: Readonly, + args?: ReadonlyArray | null, + options?: Readonly + ): ChildProcessPromise; + + export function fork( + modulePath: string, + args?: ReadonlyArray, + options?: Readonly + ): ChildProcessPromise; +} diff --git a/types/child-process-promise/tsconfig.json b/types/child-process-promise/tsconfig.json new file mode 100644 index 0000000000..0f3bf72033 --- /dev/null +++ b/types/child-process-promise/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "child-process-promise-tests.ts" + ] +} diff --git a/types/child-process-promise/tslint.json b/types/child-process-promise/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/child-process-promise/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 4cdeff6bd611ff5cfdd428c84592d950813bf30e Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 21 Mar 2019 11:22:56 +0000 Subject: [PATCH 2/8] added the correct GitHub repo on the header of the "child-process-promise"'s definition file --- types/child-process-promise/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/child-process-promise/index.d.ts b/types/child-process-promise/index.d.ts index 2740c8e197..ddc627ae9a 100644 --- a/types/child-process-promise/index.d.ts +++ b/types/child-process-promise/index.d.ts @@ -1,12 +1,11 @@ // Type definitions for child-process-promise 2.2.1 -// Project: https://github.com/TheDSCPL/types_child-process-promise +// Project: https://github.com/patrick-steele-idem/child-process-promise // Definitions by: Luis Paulo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.3.3 /// -// import child_process = require('child_process'); import { ChildProcess, ExecFileOptionsWithBufferEncoding, ExecFileOptionsWithOtherEncoding, @@ -111,3 +110,4 @@ declare namespace cpp { options?: Readonly ): ChildProcessPromise; } + From 972c8c30322b2fb367dc147cfe40749b3c06eb4f Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 21 Mar 2019 11:30:22 +0000 Subject: [PATCH 3/8] removed TypeScript version from the header of the "child-process-promise"'s definition file --- types/child-process-promise/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/child-process-promise/index.d.ts b/types/child-process-promise/index.d.ts index ddc627ae9a..ac0e06a6a8 100644 --- a/types/child-process-promise/index.d.ts +++ b/types/child-process-promise/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/patrick-steele-idem/child-process-promise // Definitions by: Luis Paulo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.3.3 /// From 7ca55fe3788d79cb863934bfd1c5677a59a89283 Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 21 Mar 2019 11:44:03 +0000 Subject: [PATCH 4/8] added "strictFunctionTypes" to "child-process-promise"'s tsconfig --- types/child-process-promise/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/child-process-promise/tsconfig.json b/types/child-process-promise/tsconfig.json index 0f3bf72033..b0f60c39eb 100644 --- a/types/child-process-promise/tsconfig.json +++ b/types/child-process-promise/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 623762f7ad6a00687ba58bbdd26f69242ea18555 Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 21 Mar 2019 12:00:00 +0000 Subject: [PATCH 5/8] implemented several of the fixes suggested by the travic bot on "child-process-promise"'s definition file --- types/child-process-promise/index.d.ts | 176 ++++++++++++------------- 1 file changed, 86 insertions(+), 90 deletions(-) diff --git a/types/child-process-promise/index.d.ts b/types/child-process-promise/index.d.ts index ac0e06a6a8..533d00c4ea 100644 --- a/types/child-process-promise/index.d.ts +++ b/types/child-process-promise/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/patrick-steele-idem/child-process-promise // Definitions by: Luis Paulo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 /// @@ -14,99 +15,94 @@ import { SpawnOptions } from 'child_process'; -export = cpp; -export as namespace cpp; - /** * Simple wrapper around the child_process module that makes use of promises */ -declare namespace cpp { - interface PromiseResult { - childProcess: ChildProcess, - stdout: Enc, - stderr: Enc - } - interface SpawnPromiseResult extends PromiseResult { - code: number - } - - interface ChildProcessPromise extends Promise { - 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, - options: Readonly - ): ChildProcessPromise>; - export function exec( - command: Readonly, - options: Readonly - ): ChildProcessPromise>; - export function exec( - command: Readonly, - options: Readonly - ): ChildProcessPromise>; - export function exec( - command: Readonly, - options?: Readonly - ): ChildProcessPromise>; - - export function execFile( - file: Readonly, - options: Readonly - ): ChildProcessPromise>; - export function execFile( - file: Readonly, - args: ReadonlyArray | null, - options: Readonly - ): ChildProcessPromise>; - export function execFile( - file: Readonly, - options: Readonly - ): ChildProcessPromise>; - export function execFile( - file: Readonly, - args: ReadonlyArray | null, - options: Readonly - ): ChildProcessPromise>; - export function execFile( - file: Readonly, - options: Readonly - ): ChildProcessPromise>; - export function execFile( - file: Readonly, - args: ReadonlyArray | null, - options: Readonly - ): ChildProcessPromise>; - export function execFile( - file: Readonly, - args?: ReadonlyArray | null - ): ChildProcessPromise>; - - export function spawn( - command: Readonly, - args?: ReadonlyArray | null, - options?: Readonly - ): ChildProcessPromise; - - export function fork( - modulePath: string, - args?: ReadonlyArray, - options?: Readonly - ): ChildProcessPromise; +interface PromiseResult { + childProcess: ChildProcess; + stdout: Enc; + stderr: Enc; } +interface SpawnPromiseResult extends PromiseResult { + code: number; +} + +interface ChildProcessPromise extends Promise { + 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, + options: Readonly +): ChildProcessPromise>; +export function exec( + command: Readonly, + options: Readonly +): ChildProcessPromise>; +export function exec( + command: Readonly, + options: Readonly +): ChildProcessPromise>; +export function exec( + command: Readonly, + options?: Readonly +): ChildProcessPromise>; + +export function execFile( + file: Readonly, + options: Readonly +): ChildProcessPromise>; +export function execFile( + file: Readonly, + args: ReadonlyArray | null, + options: Readonly +): ChildProcessPromise>; +export function execFile( + file: Readonly, + options: Readonly +): ChildProcessPromise>; +export function execFile( + file: Readonly, + args: ReadonlyArray | null, + options: Readonly +): ChildProcessPromise>; +export function execFile( + file: Readonly, + options: Readonly +): ChildProcessPromise>; +export function execFile( + file: Readonly, + args: ReadonlyArray | null, + options: Readonly +): ChildProcessPromise>; +export function execFile( + file: Readonly, + args?: ReadonlyArray | null +): ChildProcessPromise>; + +export function spawn( + command: Readonly, + args?: ReadonlyArray | null, + options?: Readonly +): ChildProcessPromise; + +export function fork( + modulePath: string, + args?: ReadonlyArray, + options?: Readonly +): ChildProcessPromise; \ No newline at end of file From a45e83be1b4e1d9b4ac167515540bada1600e785 Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 21 Mar 2019 13:10:14 +0000 Subject: [PATCH 6/8] implemented several other of the fixes suggested by the travic bot on "child-process-promise"'s definition file --- types/child-process-promise/child-process-promise-tests.ts | 2 +- types/child-process-promise/index.d.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/types/child-process-promise/child-process-promise-tests.ts b/types/child-process-promise/child-process-promise-tests.ts index c76f0c9a49..365e7e8f60 100644 --- a/types/child-process-promise/child-process-promise-tests.ts +++ b/types/child-process-promise/child-process-promise-tests.ts @@ -12,4 +12,4 @@ a.childProcess; // $ExpectType ChildProcess at.childProcess; // $ExpectType ChildProcess at.stdout; // $ExpectType string at.stderr; // $ExpectType string -})(); \ No newline at end of file +})(); diff --git a/types/child-process-promise/index.d.ts b/types/child-process-promise/index.d.ts index 533d00c4ea..7e4069cc03 100644 --- a/types/child-process-promise/index.d.ts +++ b/types/child-process-promise/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for child-process-promise 2.2.1 +// Type definitions for child-process-promise 2.2 // Project: https://github.com/patrick-steele-idem/child-process-promise // Definitions by: Luis Paulo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -19,6 +19,9 @@ import { * Simple wrapper around the child_process module that makes use of promises */ +// stop exporting everything by default +export {} + interface PromiseResult { childProcess: ChildProcess; stdout: Enc; @@ -105,4 +108,4 @@ export function fork( modulePath: string, args?: ReadonlyArray, options?: Readonly -): ChildProcessPromise; \ No newline at end of file +): ChildProcessPromise; From 99531b2ca0460648e3cedeaf22b487f4d7e42df9 Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 21 Mar 2019 13:18:06 +0000 Subject: [PATCH 7/8] implemented several other other of the fixes suggested by the travic bot on "child-process-promise"'s definition file --- types/child-process-promise/index.d.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/types/child-process-promise/index.d.ts b/types/child-process-promise/index.d.ts index 7e4069cc03..de47199ab5 100644 --- a/types/child-process-promise/index.d.ts +++ b/types/child-process-promise/index.d.ts @@ -20,7 +20,7 @@ import { */ // stop exporting everything by default -export {} +export {}; interface PromiseResult { childProcess: ChildProcess; @@ -79,11 +79,6 @@ export function execFile( file: Readonly, options: Readonly ): ChildProcessPromise>; -export function execFile( - file: Readonly, - args: ReadonlyArray | null, - options: Readonly -): ChildProcessPromise>; export function execFile( file: Readonly, options: Readonly @@ -95,7 +90,8 @@ export function execFile( ): ChildProcessPromise>; export function execFile( file: Readonly, - args?: ReadonlyArray | null + args?: ReadonlyArray | null, + options?: Readonly ): ChildProcessPromise>; export function spawn( From 089bdd6c1dba7ab17a90c5a4d89651187e3d7cb9 Mon Sep 17 00:00:00 2001 From: Luis Date: Fri, 22 Mar 2019 11:16:47 +0000 Subject: [PATCH 8/8] Changed what the reviewer asked to change --- types/child-process-promise/index.d.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/types/child-process-promise/index.d.ts b/types/child-process-promise/index.d.ts index de47199ab5..b0ea0fccf5 100644 --- a/types/child-process-promise/index.d.ts +++ b/types/child-process-promise/index.d.ts @@ -19,20 +19,17 @@ import { * Simple wrapper around the child_process module that makes use of promises */ -// stop exporting everything by default -export {}; - -interface PromiseResult { +export interface PromiseResult { childProcess: ChildProcess; stdout: Enc; stderr: Enc; } -interface SpawnPromiseResult extends PromiseResult { +export interface SpawnPromiseResult extends PromiseResult { code: number; } -interface ChildProcessPromise extends Promise { +export interface ChildProcessPromise extends Promise { childProcess: ChildProcess; }