Commit 1ef794a

Anton Golub <antongolub@antongolub.com>
2025-02-23 14:20:31
refactor: let nothrow suppress any kind of errors (#1108)
1 parent b709f2b
Changed files (1)
src/core.ts
@@ -324,7 +324,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
           if (stdout.length && getLast(getLast(stdout)) !== BR_CC) c.on.stdout!(EOL, c)
           if (stderr.length && getLast(getLast(stderr)) !== BR_CC) c.on.stderr!(EOL, c)
 
-          if (error || status !== 0 && !self.isNothrow()) {
+          if (!output.ok && !self.isNothrow()) {
             self._stage = 'rejected'
             self._reject(output)
           } else {
@@ -736,6 +736,10 @@ export class ProcessOutput extends Error {
     return 'ProcessOutput'
   }
 
+  get ok(): boolean {
+    return !this._dto.error && this.exitCode === 0
+  }
+
   [Symbol.toPrimitive](): string {
     return this.valueOf()
   }