Skip to content

Commit

Permalink
fix(types): declare $ type eхplicitly (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jun 2, 2022
1 parent 50e5f70 commit 7f0a159
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/context.ts
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/core.ts
Expand Up @@ -23,15 +23,19 @@ 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'

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))

Expand Down

0 comments on commit 7f0a159

Please sign in to comment.