Skip to content

Commit

Permalink
feat: transform some core types into ifaces to let them be extendable…
Browse files Browse the repository at this point in the history
… in plugins
  • Loading branch information
antongolub committed Jun 13, 2022
1 parent c488737 commit 700bb1e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { AsyncLocalStorage } from 'node:async_hooks'
import { spawn } from 'node:child_process'

export type Options = {
export interface Options {
verbose: boolean | number
cwd: string
env: NodeJS.ProcessEnv
Expand All @@ -30,7 +30,7 @@ export type Options = {
logIgnore?: string | string[]
}

export type Context = Options & {
export interface Context extends Options {
nothrow?: boolean
cmd: string
__from: string
Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import psTreeModule from 'ps-tree'

const psTree = promisify(psTreeModule)

interface Zx extends Options {
export interface Zx extends Options {
(pieces: TemplateStringsArray, ...args: any[]): ProcessPromise
}

Expand Down
4 changes: 2 additions & 2 deletions src/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { ProcessOutput, $ } from './core.js'
import { ProcessOutput, $, Zx } from './core.js'
import { sleep } from './goods.js'
import { isString } from './util.js'
import { getCtx, runInCtx } from './context.js'
Expand Down Expand Up @@ -81,7 +81,7 @@ export function startSpinner(title = '') {
)(setInterval(spin, 100))
}

export function ctx<R extends any>(cb: (_$: typeof $) => R): R {
export function ctx<R extends any>(cb: (_$: Zx) => R): R {
const _$ = Object.assign($.bind(null), getCtx())

return runInCtx(_$, cb, _$)
Expand Down

0 comments on commit 700bb1e

Please sign in to comment.