Skip to content

Commit 083403a

Browse files
author
evilebottnawi
committed
chore: prepare 2.0.1 release
1 parent 289cff9 commit 083403a

5 files changed

Lines changed: 74 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
This project adheres to [Semantic Versioning](http://semver.org).
66

7+
## 2.0.1 - 2018-04-19
8+
9+
* Fix: don't crash when argument is empty (string/array/object).
10+
* Fix: improve output error on empty or invalid event.
11+
712
## 2.0.0 - 2018-04-19
813

914
* Changed: remove `webpack@2` and `webpack@3` support.

__tests__/index.test.js

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,21 @@ describe("execa-webpack-plugin", () => {
5656
const dir = path.join(__dirname, "dir");
5757
const otherDir = path.join(__dirname, "other-dir");
5858

59-
it("should throw error when `on*` options are empty (no events)", () =>
59+
it("should throw error on `on*` options are empty (no events)", () =>
6060
expect(() => run()).toThrow());
6161

62+
it("should throw error invalid `onFooBar` option (no events)", () =>
63+
expect(() =>
64+
run({
65+
onFooBar: [
66+
{
67+
args: [path.join(resourcesDir, "nothing.js")],
68+
cmd: "node"
69+
}
70+
]
71+
})
72+
).toThrow());
73+
6274
it("should works with `on*` options", () =>
6375
run({
6476
onAdditionalPass: [
@@ -234,6 +246,29 @@ describe("execa-webpack-plugin", () => {
234246
});
235247
});
236248

249+
it("should works with `onCompile` option with empty argument (sync event) ", () => {
250+
expect.assertions(2);
251+
252+
mkdirSyncSafe(dir);
253+
254+
expect(fs.statSync(dir).isDirectory()).toBe(true);
255+
256+
return run({
257+
onCompile: [
258+
{
259+
args: [dir, "", [], {}],
260+
cmd: "del"
261+
}
262+
]
263+
}).then(() => {
264+
expect(() => fs.statSync(dir)).toThrow();
265+
266+
unlinkSyncSafe(dir);
267+
268+
return Promise.resolve();
269+
});
270+
});
271+
237272
it("should works with `onCompile` and `dev` is `false` option (sync event)", () => {
238273
expect.assertions(2);
239274

@@ -282,6 +317,29 @@ describe("execa-webpack-plugin", () => {
282317
});
283318
});
284319

320+
it("should works with `onDone` option with empty argument (async event) ", () => {
321+
expect.assertions(2);
322+
323+
mkdirSyncSafe(dir);
324+
325+
expect(fs.statSync(dir).isDirectory()).toBe(true);
326+
327+
return run({
328+
onDone: [
329+
{
330+
args: [dir, "", [], {}],
331+
cmd: "del"
332+
}
333+
]
334+
}).then(() => {
335+
expect(() => fs.statSync(dir)).toThrow();
336+
337+
unlinkSyncSafe(dir);
338+
339+
return Promise.resolve();
340+
});
341+
});
342+
285343
it("should works with `onDone` and `dev` is `false` options (async event)", () => {
286344
expect.assertions(2);
287345

index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ChildProcessWebpackPlugin {
5656
});
5757

5858
if (Object.keys(this.eventMap).length === 0) {
59-
throw new TypeError("No events found");
59+
throw new TypeError("Known events not found");
6060
}
6161

6262
this.log = weblog({
@@ -139,7 +139,11 @@ class ChildProcessWebpackPlugin {
139139
const args = process.args || [];
140140

141141
args.forEach((arg, index) => {
142-
if (typeof arg === "object" && Boolean(arg)) {
142+
if (
143+
typeof arg === "object" &&
144+
Boolean(arg) &&
145+
Object.keys(arg).length > 0
146+
) {
143147
const commandResult = this.execute([arg], async);
144148

145149
process.args[index] = Array.isArray(commandResult)
@@ -155,7 +159,7 @@ class ChildProcessWebpackPlugin {
155159
if (async) {
156160
result = Promise.all(args).then(resolvedArgs => {
157161
process.args = resolvedArgs.map(
158-
item => (item[0].stdout ? item[0].stdout : item)
162+
item => (item[0] && item[0].stdout ? item[0].stdout : item)
159163
);
160164

161165
return this.runCommand(process, async);
@@ -167,11 +171,7 @@ class ChildProcessWebpackPlugin {
167171
results.push(result);
168172
});
169173

170-
return async
171-
? Promise.all(results).catch(error => {
172-
this.handleError(error, process);
173-
})
174-
: results;
174+
return async ? Promise.all(results) : results;
175175
}
176176

177177
apply(compiler) {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "execa-webpack-plugin",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "A better `child_process` for `webpack`",
55
"keywords": [
66
"exec",

0 commit comments

Comments
 (0)