UNPKG

@hyperse/exec-program

Version:

Executes a command using `file ...arguments`, supports `.ts` file for esm type module.

43 lines (38 loc) 1.45 kB
import { Options, ResultPromise } from 'execa'; type ExecOptions = Options; type ExecResultPromise<T extends Options = Options> = ResultPromise<T>; /** * Execute a file with arguments and options * @example * ```ts * const { stdout, stderr } = await execute( * 'npm', * ['i', '--no-save', '--no-package-lock', ...toInstall], * { * cwd: target.directory, * maxBuffer: TEN_MEGA_BYTE, * env: this.options.npmEnv, * } * ); * ``` * @example * ```ts * await execute('npm', ['pack', directory], { * cwd: this.uniqueDir, * maxBuffer: TEN_MEGA_BYTE, * }); * ``` * @param file - The program/script to execute, as a string or file URL * @param args - Arguments to pass to `file` on execution. * @param options - Options to pass to `execa` * @returns A `ResultPromise` that is both: */ declare function execute<T extends ExecOptions>(file: string, args?: readonly string[], options?: T): ExecResultPromise<{} & T>; /** * Process execute typescript script file using `@hyperse/ts-node` * @param program - The absolute typescript file path * @param options - The configuration of `execa` { env: { HPS_TS_NODE_PROJECT: tsconfig } } * @param args - The runtime argv for program */ declare const runTsScript: <T extends ExecOptions>(program: string, args?: readonly string[], options?: T) => ExecResultPromise<{} & T>; export { type ExecOptions, type ExecResultPromise, execute, runTsScript };