Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not swallow other errors when there are unfinished hook actions
- Loading branch information
1 parent
a4d6a4e
commit f8b2ca7
Showing
8 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/cli/samples/unfulfilled-hook-actions-error/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const assert = require('assert'); | ||
const { assertIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'does not swallow errors on unfulfilled hooks actions', | ||
minNodeVersion: 13, | ||
command: 'node build.mjs', | ||
after(err) { | ||
// exit code check has to be here as error(err) is only called upon failure | ||
assert.strictEqual(err && err.code, 1); | ||
}, | ||
error() { | ||
// do not abort test upon error | ||
return true; | ||
}, | ||
stderr(stderr) { | ||
assertIncludes(stderr, '[!] Error: unfinished hook action(s) on exit'); | ||
assertIncludes(stderr, '(test) transform'); | ||
assertIncludes(stderr, 'Error: Error must be displayed.'); | ||
} | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('a'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('b'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { rollup } from 'rollup'; | ||
|
||
let resolveA; | ||
const waitForA = new Promise(resolve => (resolveA = resolve)); | ||
|
||
// The error must not be swallowed when using top-level-await | ||
await rollup({ | ||
input: './index.js', | ||
plugins: [ | ||
{ | ||
name: 'test', | ||
transform(code, id) { | ||
if (id.endsWith('a.js')) { | ||
resolveA(); | ||
return new Promise(() => {}); | ||
} | ||
if (id.endsWith('b.js')) { | ||
return waitForA.then(() => Promise.reject(new Error('Error must be displayed.'))) | ||
} | ||
} | ||
} | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('c'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './a.js'; | ||
import './b.js'; | ||
import './c.js'; |