Commit 7138b05
Changed files (4)
build/core.cjs
@@ -806,6 +806,7 @@ var _ProcessPromise = class _ProcessPromise extends Promise {
}
}
if (memo[0]) yield memo[0];
+ if (this.isNothrow()) return;
if ((yield new __await(this.exitCode)) !== 0) throw this._output;
});
}
src/core.ts
@@ -647,6 +647,8 @@ export class ProcessPromise extends Promise<ProcessOutput> {
if (memo[0]) yield memo[0]
+ if (this.isNothrow()) return
+
if ((await this.exitCode) !== 0) throw this._output
}
test/core.test.js
@@ -1048,6 +1048,14 @@ describe('core', () => {
'The process exit code should be 1'
)
})
+
+ it('handles .nothrow() correctly', async () => {
+ const data = []
+ for await (const line of $({ nothrow: true })`grep any test`) {
+ data.push(line)
+ }
+ assert.equal(data.length, 0, 'Should not yield any lines')
+ })
})
test('quiet() mode is working', async () => {
@@ -1083,8 +1091,10 @@ describe('core', () => {
})
test('nothrow() does not throw', async () => {
- const { exitCode } = await $`exit 42`.nothrow()
- assert.equal(exitCode, 42)
+ {
+ const { exitCode } = await $`exit 42`.nothrow()
+ assert.equal(exitCode, 42)
+ }
{
// Toggle
try {
.size-limit.json
@@ -45,7 +45,7 @@
{
"name": "all",
"path": ["build/*", "man/*", "README.md", "LICENSE"],
- "limit": "872.6 kB",
+ "limit": "872.65 kB",
"brotli": false,
"gzip": false
}