Files
renovate/lib/util/exec/common.ts
T

53 lines
1.1 KiB
TypeScript

import {
exec as cpExec,
ExecOptions as ChildProcessExecOptions,
} from 'child_process';
import { promisify } from 'util';
export type Opt<T> = T | null | undefined;
export enum BinarySource {
Auto = 'auto',
Docker = 'docker',
Global = 'global',
}
export interface ExecConfig {
binarySource: Opt<BinarySource>;
dockerUser: Opt<string>;
localDir: Opt<string>;
cacheDir: Opt<string>;
}
export type VolumesPair = [string, string];
export type VolumeOption = Opt<string | VolumesPair>;
export type DockerExtraCommand = Opt<string>;
export type DockerExtraCommands = Opt<DockerExtraCommand[]>;
export interface DockerOptions {
image: string;
tag?: Opt<string>;
tagScheme?: Opt<string>;
tagConstraint?: Opt<string>;
volumes?: Opt<VolumeOption[]>;
envVars?: Opt<Opt<string>[]>;
cwd?: Opt<string>;
preCommands?: DockerExtraCommands;
postCommands?: DockerExtraCommands;
}
export interface RawExecOptions extends ChildProcessExecOptions {
encoding: string;
}
export interface ExecResult {
stdout: string;
stderr: string;
}
export const rawExec: (
cmd: string,
opts: RawExecOptions
) => Promise<ExecResult> = promisify(cpExec);