Skip to content

Commit 3b9069b

Browse files
committed
throw an error when using wrong spelling of an option
1 parent bdb73b4 commit 3b9069b

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ module.exports = function nodeExternals(options) {
2626
var mistakes = utils.validateOptions(options) || [];
2727
if (mistakes.length) {
2828
mistakes.forEach(function (mistake) {
29+
utils.error(
30+
mistakes.map(function (mistake) {
31+
return mistake.message;
32+
})
33+
);
2934
utils.log(mistake.message);
3035
});
3136
}

utils.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ exports.validateOptions = function (options) {
102102
var mistakes = {
103103
allowlist: ['allowslist', 'whitelist', 'allow'],
104104
importType: ['import', 'importype', 'importtype'],
105-
modulesDir: ['moduleDir', 'moduledir', 'moduledirs'],
105+
modulesDir: ['moduledir', 'moduledirs'],
106106
modulesFromFile: ['modulesfile'],
107-
includeAbsolutePaths: ['includeAbsolutePaths'],
107+
includeAbsolutePaths: ['includeAbsolutesPaths'],
108108
additionalModuleDirs: ['additionalModulesDirs', 'additionalModulesDir'],
109109
};
110110
var optionsKeys = Object.keys(options);
@@ -130,6 +130,16 @@ exports.validateOptions = function (options) {
130130
return results;
131131
};
132132

133-
exports.log = function(message) {
134-
console.log(`[webpack-node-externals] : ${message}`)
135-
}
133+
exports.log = function (message) {
134+
console.log(`[webpack-node-externals] : ${message}`);
135+
};
136+
137+
exports.error = function (errors) {
138+
throw new Error(
139+
errors
140+
.map(function (error) {
141+
return `[webpack-node-externals] : ${error}`;
142+
})
143+
.join('\r\n')
144+
);
145+
};

0 commit comments

Comments
 (0)