Skip to content

Commit 7db078e

Browse files
fix: do not crash on empty async hook (#42)
1 parent 900fc38 commit 7db078e

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
<!--lint disable -->
4+
<!-- prettier-ignore-start -->
5+
36
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
47

58
### [6.0.1](https://github.com/itgalaxy/execa-webpack-plugin/compare/v6.0.0...v6.0.1) (2020-02-26)
@@ -97,3 +100,5 @@ All notable changes to this project will be documented in this file. See [standa
97100
## 1.0.0 - 2017-12-22
98101

99102
- Chore: public initial release.
103+
104+
<!-- prettier-ignore-end -->

__tests__/__snapshots__/index.test.js.snap

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,33 @@ Array [
134134

135135
exports[`execa-webpack-plugin should not throw error with 'bail: false' option (sync hook): warnings 1`] = `Array []`;
136136

137-
exports[`execa-webpack-plugin should output warning on empty hook: logs 1`] = `
137+
exports[`execa-webpack-plugin should output warning on empty async hook: logs 1`] = `
138+
Array [
139+
Array [
140+
"ExecaPlugin",
141+
"log",
142+
Array [
143+
"Running the \\"done\\" hook",
144+
],
145+
],
146+
Array [
147+
"ExecaPlugin",
148+
"warn",
149+
Array [
150+
"No commands found for the \\"done\\" hook",
151+
],
152+
],
153+
Array [
154+
"ExecaPlugin",
155+
"log",
156+
Array [
157+
"The \\"done\\" hook completed",
158+
],
159+
],
160+
]
161+
`;
162+
163+
exports[`execa-webpack-plugin should output warning on empty sync hook: logs 1`] = `
138164
Array [
139165
Array [
140166
"ExecaPlugin",

__tests__/helpers/normalize-errors.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ function removeCWD(str) {
1010
}
1111

1212
if (isWin) {
13-
// eslint-disable-next-line no-param-reassign, unicorn/prefer-replace-all
13+
// eslint-disable-next-line no-param-reassign
1414
str = str.replace(/\\/g, "/");
15-
// eslint-disable-next-line unicorn/prefer-replace-all
1615
cwd = cwd.replace(/\\/g, "/");
1716
}
1817

__tests__/index.test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,22 @@ describe("execa-webpack-plugin", () => {
146146
expect(logs).toMatchSnapshot("logs");
147147
});
148148

149-
it("should output warning on empty hook", async () => {
149+
it("should output warning on empty sync hook", async () => {
150150
await compile({
151151
onCompile: []
152152
});
153153

154154
expect(logs).toMatchSnapshot("logs");
155155
});
156156

157+
it("should output warning on empty async hook", async () => {
158+
await compile({
159+
onDone: []
160+
});
161+
162+
expect(logs).toMatchSnapshot("logs");
163+
});
164+
157165
it("should work with 'on*' options", async () => {
158166
const stats = await compile({
159167
onShouldEmit: [

src/ExecaWebpackPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class ExecaPlugin {
135135
)}" hook`
136136
);
137137

138-
return [];
138+
return Promise.resolve();
139139
}
140140

141141
const results = commands

0 commit comments

Comments
 (0)