throw on unknown options

This commit is contained in:
Sebastian McKenzie
2015-01-23 09:26:27 +11:00
parent 36fa887be8
commit 49cd1753e6

View File

@@ -46,9 +46,39 @@ File.helpers = [
"get"
];
File.validOptions = [
"filename",
"fileNameRelative",
"blacklist",
"whitelist",
"optional",
"modules",
"sourceMap",
"sourceMapName",
"sourceFileName",
"sourceRoot",
"moduleRoot",
"moduleIds",
"runtime",
"comments",
"reactCompat",
"keepModuleIdExtensions",
"code",
"ast",
"format",
"playground",
"experimental"
];
File.normaliseOptions = function (opts) {
opts = _.cloneDeep(opts || {});
for (var key in opts) {
if (File.validOptions.indexOf(key) < 0) {
throw new ReferenceError("Unknown option: " + key);
}
}
_.defaults(opts, {
keepModuleIdExtensions: false,
experimental: false,