UNPKG

1.56 kBTypeScriptView Raw
1/// <reference types="node" />
2import { PortablePath, FakeFS } from '@yarnpkg/fslib';
3import { Readable, Writable } from 'stream';
4import { ProcessImplementation } from './pipe';
5export declare type Glob = {
6 isGlobPattern: (arg: string) => boolean;
7 match: (pattern: string, options: {
8 cwd: PortablePath;
9 fs?: FakeFS<PortablePath>;
10 }) => Promise<Array<string>>;
11};
12export declare type UserOptions = {
13 builtins: {
14 [key: string]: ShellBuiltin;
15 };
16 cwd: PortablePath;
17 env: {
18 [key: string]: string | undefined;
19 };
20 stdin: Readable | null;
21 stdout: Writable;
22 stderr: Writable;
23 variables: {
24 [key: string]: string;
25 };
26 glob: Glob;
27};
28export declare type ShellBuiltin = (args: Array<string>, opts: ShellOptions, state: ShellState) => Promise<number>;
29export declare type ShellOptions = {
30 args: Array<string>;
31 builtins: Map<string, ShellBuiltin>;
32 initialStdin: Readable;
33 initialStdout: Writable;
34 initialStderr: Writable;
35 glob: Glob;
36};
37export declare type ShellState = {
38 cwd: PortablePath;
39 environment: {
40 [key: string]: string;
41 };
42 exitCode: number | null;
43 procedures: {
44 [key: string]: ProcessImplementation;
45 };
46 stdin: Readable;
47 stdout: Writable;
48 stderr: Writable;
49 variables: {
50 [key: string]: string;
51 };
52};
53export declare function execute(command: string, args?: Array<string>, { builtins, cwd, env, stdin, stdout, stderr, variables, glob, }?: Partial<UserOptions>): Promise<number>;