Skip to content

Commit

Permalink
refactor: align ProcessPromise.isSmth() API (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed May 27, 2024
1 parent f5545ef commit 851e50f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const $: Shell & Options = new Proxy<Shell & Options>(
) as string
const snapshot = getStore()
const sync = snapshot[syncExec]
const callback = () => promise.isHalted || promise.run()
const callback = () => promise.isHalted() || promise.run()

promise._bind(
cmd,
Expand Down Expand Up @@ -329,7 +329,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
message
)
self._output = output
if (status === 0 || (self._nothrow ?? $.nothrow)) {
if (status === 0 || self.isNothrow()) {
self._resolve(output)
} else {
self._reject(output)
Expand Down Expand Up @@ -410,7 +410,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
| undefined
| null
): Promise<R | E> {
if (this.isHalted && !this.child) {
if (this.isHalted() && !this.child) {
throw new Error('The process is halted!')
}
return super.then(onfulfilled, onrejected)
Expand Down Expand Up @@ -506,6 +506,10 @@ export class ProcessPromise extends Promise<ProcessOutput> {
return (this._verbose ?? this._snapshot.verbose) && !this.isQuiet()
}

isNothrow(): boolean {
return this._nothrow ?? this._snapshot.nothrow
}

timeout(d: Duration, signal = 'SIGTERM'): ProcessPromise {
this._timeout = parseDuration(d)
this._timeoutSignal = signal
Expand All @@ -517,7 +521,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
return this
}

get isHalted(): boolean {
isHalted(): boolean {
return this._halted
}

Expand Down

0 comments on commit 851e50f

Please sign in to comment.