Skip to content

Commit be40f6d

Browse files
authored
change some constructs to ES2015
1 parent 34cf2ac commit be40f6d

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎lib/EnvironmentPlugin.js‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,39 @@ const DefinePlugin = require("./DefinePlugin");
99

1010
class EnvironmentPlugin {
1111
constructor(keys) {
12-
this.defaultValues = {};
13-
1412
if(Array.isArray(keys)) {
1513
this.keys = keys;
14+
this.defaultValues = {};
1615
} else if(keys && typeof keys === "object") {
1716
this.keys = Object.keys(keys);
1817
this.defaultValues = keys;
1918
} else {
2019
this.keys = Array.prototype.slice.call(arguments);
20+
this.defaultValues = {};
2121
}
2222
}
2323

2424
apply(compiler) {
25-
const definitions = this.keys.reduce(function(defs, key) {
25+
const definitions = this.keys.reduce((defs, key) => {
2626
const value = process.env[key] || this.defaultValues[key];
2727

2828
if(value === undefined) {
29-
compiler.plugin("this-compilation", function(compilation) {
29+
compiler.plugin("this-compilation", compilation => {
3030
const error = new Error(
31-
"EnvironmentPlugin - " + key + " environment variable is undefined. \n\n" +
32-
"You can pass an object with default values to suppress this warning. \n" +
33-
"See https://webpack.js.org/plugins/environment-plugin for example."
31+
`EnvironmentPlugin - ${key} environment variable is undefined.\n\n` +
32+
`You can pass an object with default values to suppress this warning.\n` +
33+
`See https://webpack.js.org/plugins/environment-plugin for example.`
3434
);
3535

3636
error.name = "EnvVariableNotDefinedError";
3737
compilation.warnings.push(error);
3838
});
3939
}
4040

41-
defs["process.env." + key] = value === undefined ? "undefined" : JSON.stringify(value);
41+
defs[`process.env.${key}`] = value === undefined ? "undefined" : JSON.stringify(value);
4242

4343
return defs;
44-
}.bind(this), {});
44+
}, {});
4545

4646
compiler.apply(new DefinePlugin(definitions));
4747
}

0 commit comments

Comments
 (0)