Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions types/hexo-util/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// <reference types="node" />

import { Transform } from "stream";
import { SpawnOptions } from 'child_process';
import { SpawnOptions, StdioOptions } from 'child_process';

export class CacheStream extends Transform {
destroy(): void;
Expand Down Expand Up @@ -79,11 +79,11 @@ export interface hexoSpawnDisableEncodingOptions extends SpawnOptions {
}

export interface hexoSpawnOverrideStdioOptions extends hexoSpawnOptions {
stdio: any[] | string;
stdio: StdioOptions;
}

export interface hexoSpawnDisableEncodingAndOverrideStdioOptions extends hexoSpawnDisableEncodingOptions {
stdio: any[] | string;
stdio: StdioOptions;
}

export function spawn(command: string, args: string[], options: hexoSpawnDisableEncodingAndOverrideStdioOptions): Promise<Buffer | undefined>;
Expand Down
47 changes: 25 additions & 22 deletions types/node/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2190,11 +2190,13 @@ declare module "child_process" {
keepOpen?: boolean;
}

export type StdioOptions = "pipe" | "ignore" | "inherit" | Array<("pipe" | "ipc" | "ignore" | stream.Stream | number | null | undefined)>;

export interface SpawnOptions {
argv0?: string;
cwd?: string;
env?: any;
stdio?: any;
env?: NodeJS.ProcessEnv;
argv0?: string;
stdio?: StdioOptions;
detached?: boolean;
uid?: number;
gid?: number;
Expand All @@ -2207,7 +2209,7 @@ declare module "child_process" {

export interface ExecOptions {
cwd?: string;
env?: any;
env?: NodeJS.ProcessEnv;
shell?: string;
timeout?: number;
maxBuffer?: number;
Expand Down Expand Up @@ -2262,7 +2264,7 @@ declare module "child_process" {

export interface ExecFileOptions {
cwd?: string;
env?: any;
env?: NodeJS.ProcessEnv;
timeout?: number;
maxBuffer?: number;
killSignal?: string;
Expand Down Expand Up @@ -2329,32 +2331,32 @@ declare module "child_process" {

export interface ForkOptions {
cwd?: string;
env?: any;
env?: NodeJS.ProcessEnv;
execPath?: string;
execArgv?: string[];
silent?: boolean;
stdio?: any[];
stdio?: StdioOptions;
windowsVerbatimArguments?: boolean;
uid?: number;
gid?: number;
windowsVerbatimArguments?: boolean;
}
export function fork(modulePath: string, args?: ReadonlyArray<string>, options?: ForkOptions): ChildProcess;

export interface SpawnSyncOptions {
argv0?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite sure that argv0 argument is also supported for sync even if it is missing in node docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem pretty unlikely that spawnsync wouldn't end up reusing most of the logic from spawn (or vice versa). I'll put the option back here and see about getting the Node docs fixed -- if it turns out you really can't, I'll open a separate PR to take it out, I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That didn't take long: found it. Definitely uses the same logic for both functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node PR is up.

argv0?: string; // Not specified in the docs
cwd?: string;
input?: string | Buffer;
stdio?: any;
env?: any;
input?: string | Buffer | Uint8Array;
stdio?: StdioOptions;
env?: NodeJS.ProcessEnv;
uid?: number;
gid?: number;
timeout?: number;
killSignal?: string;
killSignal?: string | number;
maxBuffer?: number;
encoding?: string;
shell?: boolean | string;
windowsHide?: boolean;
windowsVerbatimArguments?: boolean;
windowsHide?: boolean;
}
export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
encoding: BufferEncoding;
Expand All @@ -2381,14 +2383,14 @@ declare module "child_process" {

export interface ExecSyncOptions {
cwd?: string;
input?: string | Buffer;
stdio?: any;
env?: any;
input?: string | Buffer | Uint8Array;
stdio?: StdioOptions;
env?: NodeJS.ProcessEnv;
shell?: string;
uid?: number;
gid?: number;
timeout?: number;
killSignal?: string;
killSignal?: string | number;
maxBuffer?: number;
encoding?: string;
windowsHide?: boolean;
Expand All @@ -2406,16 +2408,17 @@ declare module "child_process" {

export interface ExecFileSyncOptions {
cwd?: string;
input?: string | Buffer;
stdio?: any;
env?: any;
input?: string | Buffer | Uint8Array;
stdio?: StdioOptions;
env?: NodeJS.ProcessEnv;
uid?: number;
gid?: number;
timeout?: number;
killSignal?: string;
killSignal?: string | number;
maxBuffer?: number;
encoding?: string;
windowsHide?: boolean;
shell?: boolean | string;
}
export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
encoding: BufferEncoding;
Expand Down
1 change: 1 addition & 0 deletions types/node/node-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,7 @@ namespace child_process_tests {
childProcess.exec("echo test", { windowsHide: true });
childProcess.spawn("echo", ["test"], { windowsHide: true });
childProcess.spawn("echo", ["test"], { windowsHide: true, argv0: "echo-test" });
childProcess.spawn("echo", ["test"], { stdio: [0xdeadbeef, undefined, "pipe"] });
childProcess.spawnSync("echo test");
childProcess.spawnSync("echo test", {windowsVerbatimArguments: false});
childProcess.spawnSync("echo test", {windowsVerbatimArguments: false, argv0: "echo-test"});
Expand Down