From 84f5d623643f957bb4280a8ee8e6ba14e4ffb15e Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Thu, 2 Jun 2022 20:34:34 +0300 Subject: [PATCH] =?UTF-8?q?fix(types):=20declare=20$=20type=20e=D1=85plici?= =?UTF-8?q?tly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/context.ts | 2 ++ src/core.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/context.ts b/src/context.ts index ac87e0d4c6..7d0b702baf 100644 --- a/src/context.ts +++ b/src/context.ts @@ -13,6 +13,7 @@ // limitations under the License. import { AsyncLocalStorage } from 'node:async_hooks' +import { spawn} from 'node:child_process' export type Options = { verbose: boolean | number @@ -22,6 +23,7 @@ export type Options = { shell: string maxBuffer: number quote: (v: string) => string + spawn: typeof spawn logOutput?: 'stdout' | 'stderr' logFormat?: (...msg: any[]) => string | string[] logPrint?: (data: any, err?: any) => void diff --git a/src/core.ts b/src/core.ts index c18bbdff33..9ce7770e49 100644 --- a/src/core.ts +++ b/src/core.ts @@ -23,7 +23,7 @@ import { inspect, promisify } from 'node:util' import { spawn } from 'node:child_process' import { chalk, which } from './goods.js' -import { runInCtx, getCtx, setRootCtx, Context } from './context.js' +import { runInCtx, getCtx, setRootCtx, Context, Options } from './context.js' import { printCmd, log } from './print.js' import { quote, substitute } from './guards.js' @@ -31,7 +31,11 @@ import psTreeModule from 'ps-tree' const psTree = promisify(psTreeModule) -export function $(pieces: TemplateStringsArray, ...args: any[]) { +interface Zx extends Options { + (pieces: TemplateStringsArray, ...args: any[]): ProcessPromise +} + +export const $: Zx = function (pieces: TemplateStringsArray, ...args: any[]) { let resolve, reject let promise = new ProcessPromise((...args) => ([resolve, reject] = args))