Skip to content

Commit

Permalink
throw an error when using wrong spelling of an option
Browse files Browse the repository at this point in the history
  • Loading branch information
liady committed Jul 12, 2020
1 parent bdb73b4 commit 3b9069b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ module.exports = function nodeExternals(options) {
var mistakes = utils.validateOptions(options) || [];
if (mistakes.length) {
mistakes.forEach(function (mistake) {
utils.error(
mistakes.map(function (mistake) {
return mistake.message;
})
);
utils.log(mistake.message);
});
}
Expand Down
20 changes: 15 additions & 5 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ exports.validateOptions = function (options) {
var mistakes = {
allowlist: ['allowslist', 'whitelist', 'allow'],
importType: ['import', 'importype', 'importtype'],
modulesDir: ['moduleDir', 'moduledir', 'moduledirs'],
modulesDir: ['moduledir', 'moduledirs'],
modulesFromFile: ['modulesfile'],
includeAbsolutePaths: ['includeAbsolutePaths'],
includeAbsolutePaths: ['includeAbsolutesPaths'],
additionalModuleDirs: ['additionalModulesDirs', 'additionalModulesDir'],
};
var optionsKeys = Object.keys(options);
Expand All @@ -130,6 +130,16 @@ exports.validateOptions = function (options) {
return results;
};

exports.log = function(message) {
console.log(`[webpack-node-externals] : ${message}`)
}
exports.log = function (message) {
console.log(`[webpack-node-externals] : ${message}`);
};

exports.error = function (errors) {
throw new Error(
errors
.map(function (error) {
return `[webpack-node-externals] : ${error}`;
})
.join('\r\n')
);
};

0 comments on commit 3b9069b

Please sign in to comment.