From d404694c897d48f8c95d872d1a4dd5c35253373c Mon Sep 17 00:00:00 2001 From: Simon He <57086651+Simon-He95@users.noreply.github.com> Date: Sun, 25 Feb 2024 17:31:31 +0800 Subject: [PATCH] chore: update --- src/node/jsShell.ts | 17 +++++++++++++++-- src/worker/useNodeWorkerThread.ts | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/node/jsShell.ts b/src/node/jsShell.ts index 822520b..9446090 100644 --- a/src/node/jsShell.ts +++ b/src/node/jsShell.ts @@ -19,9 +19,22 @@ interface Options { } export function jsShell( commander: T, - options: Options = {}, + options: Options | 'inherit' | 'pipe' = 'inherit', ) { - const { args = [], stdio = 'inherit', errorExit, isLog, cwd } = options + let args: string[] = [] + let stdio: 'inherit' | 'pipe' = 'inherit' + let errorExit: boolean = true + let isLog: boolean = false + let cwd: string | undefined + if (typeof options === 'string') { + stdio = options + } else { + args = options.args || [] + stdio = options.stdio || 'inherit' + errorExit = options.errorExit || true + isLog = options.isLog || false + cwd = options.cwd + } return ( isArray(commander) diff --git a/src/worker/useNodeWorkerThread.ts b/src/worker/useNodeWorkerThread.ts index 431ce72..7dc954d 100644 --- a/src/worker/useNodeWorkerThread.ts +++ b/src/worker/useNodeWorkerThread.ts @@ -4,5 +4,5 @@ import { jsShell } from '../node/jsShell' useProcressNodeWorker( ({ params, stdio = 'pipe', errorExit, isLog }: NodeWorkerPayload) => - jsShell(`${params}`, stdio, errorExit, isLog), + jsShell(`${params}`, { stdio, errorExit, isLog }), )