UNPKG

@aws-cdk-testing/cli-integ

Version:

Integration tests for the AWS CDK CLI

112 lines (111 loc) 3.49 kB
import type * as child_process from 'child_process'; import type { TestContext } from './integ-test'; import type { TemporaryDirectoryContext } from './with-temporary-directory'; /** * A shell command that does what you want * * Is platform-aware, handles errors nicely. */ export declare function shell(command: string[], options?: ShellOptions): Promise<string>; /** * Models a single user interaction with the shell. */ export interface UserInteraction { /** * The prompt to expect. Regex matched against the last line in * the output before the prompt is displayed. * * Most commonly this would be a simple string to match for inclusion. * * Examples: * * - Process Output: "Hey there! Are you sure?" * Prompt: /Are you sure?/ * Match (Yes/No): Yes * Reason: "Hey there! Are you sure?" ~ /Are you sure?/ * * - Process Output: "Hey there!\nAre you sure?" * Prompt: /Are you sure?/ * Match (Yes/No): Yes * Reason: "Are you sure?" ~ /Are you sure?/ * * - Process Output: "Are you sure?\n(remember this is destructive)" * Prompt: /Are you sure?/ * Match (Yes/No): No * Reason: "(remember this is destructive)" ≄ /Are you sure?/ * * - Process Output: "Are you sure?\n(remember this is destructive)" * Prompt: /remember this is destructive/ * Match (Yes/No): Yes * Reason: "(remember this is destructive)" ~ /remember this is destructive/ * */ readonly prompt: RegExp; /** * The input to provide. */ readonly input: string; /** * The string to signal the end of input. * * @default os.EOL */ readonly end?: string; } export interface ShellOptions extends child_process.SpawnOptions { /** * Properties to add to 'env' */ readonly modEnv?: Record<string, string | undefined>; /** * Don't fail when exiting with an error * * @default false */ readonly allowErrExit?: boolean; /** * Whether to capture stderr * * @default true */ readonly captureStderr?: boolean; /** * Pass output here */ readonly outputs?: NodeJS.WritableStream[]; /** * Only return stderr. For example, this is used to validate * that when CI=true, all logs are sent to stdout. * * @default false */ readonly onlyStderr?: boolean; /** * Don't log to stdout * * @default always */ readonly show?: 'always' | 'never' | 'error'; /** * Provide user interaction to respond to shell prompts. * * Order and count should correspond to the expected prompts issued by the subprocess. */ readonly interact?: UserInteraction[]; } export declare class ShellHelper { private readonly _cwd; private readonly _output; static fromContext(context: TestContext & TemporaryDirectoryContext): ShellHelper; constructor(_cwd: string, _output: NodeJS.WritableStream); get dockerConfigDir(): string; shell(command: string[], options?: Omit<ShellOptions, 'cwd' | 'outputs'>): Promise<string>; } /** * rm -rf reimplementation, don't want to depend on an NPM package for this * * Returns `true` if everything got deleted, or `false` if some files could * not be deleted due to permissions issues. */ export declare function rimraf(fsPath: string): boolean; export declare function addToShellPath(x: string): void;