Skip to content

Commit 454bb91

Browse files
committed
allow input to be string.
1 parent 77a1aec commit 454bb91

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ module.exports = config;
4747
Once the build finishes, a child process is spawned firing both a python and node script.
4848

4949
### API
50-
* onBuildStart: **Array[ ]**, array of scripts to execute on the initial build. **Default: [ ]**
51-
* onBuildEnd: **Array[ ]**, array of scripts to execute after files are emitted. **Default: [ ]**
52-
* dev: **Boolean**, switch for development environments. This causes scripts to only execute once. Useful for running HMR on webpack-dev-server. **Default: false**
50+
* onBuildStart: array of scripts to execute on the initial build. **Default: [ ]**
51+
* onBuildEnd: array of scripts to execute after files are emitted at the end of the compilation. **Default: [ ]**
52+
* dev: switch for development environments. This causes scripts to only execute once. Useful for running HMR on webpack-dev-server. **Default: true**
53+
* verbose: enable for verbose output. **Default: false**
5354

5455
### Contributions
55-
[Yair Tavor]("http://stackoverflow.com/users/3054454/yair-tavor")
56+
Yair Tavor
5657

index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,24 @@ function puts(error, stdout, stderr) {
99
}
1010
}
1111

12+
function validateInput(options) {
13+
if (typeof options.onBuildStart === 'string') {
14+
options.onBuildStart = options.onBuildStart.split('&&');
15+
}
16+
if (typeof options.onBuildEnd === 'string') {
17+
options.onBuildEnd = options.onBuildEnd.split('&&');
18+
}
19+
return options;
20+
}
21+
1222
function WebpackShellPlugin(options) {
1323
var defaultOptions = {
1424
onBuildStart: [],
1525
onBuildEnd: [],
16-
dev: false,
26+
dev: true,
1727
verbose: false
1828
};
29+
1930
if (!options.onBuildStart) {
2031
options.onBuildStart = defaultOptions.onBuildStart;
2132
}
@@ -24,6 +35,13 @@ function WebpackShellPlugin(options) {
2435
options.onBuildEnd = defaultOptions.onBuildEnd;
2536
}
2637

38+
options = validateInput(options);
39+
40+
41+
if (!options.dev) {
42+
options.dev = defaultOptions.dev;
43+
}
44+
2745
this.options = options;
2846

2947
}

0 commit comments

Comments
 (0)