Skip to content

Commit b1078b8

Browse files
committed
Check es6 default export against null, swapped null check in processConfiguredOptions
1 parent acccd86 commit b1078b8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

bin/convert-argv.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ module.exports = function(optimist, argv, convertOptions) {
9494
configFileLoaded = true;
9595
}
9696

97-
var isES6DefaultExportedFunc = (typeof options === "object" && typeof options["default"] === "function");
97+
var isES6DefaultExportedFunc = (
98+
typeof options === "object" && options !== null && typeof options["default"] === "function"
99+
);
100+
98101
if(typeof options === "function" || isES6DefaultExportedFunc) {
99102
options = isES6DefaultExportedFunc ? options.default : options;
100103
options = options(argv.env, argv);
@@ -103,7 +106,7 @@ module.exports = function(optimist, argv, convertOptions) {
103106
return processConfiguredOptions(options);
104107

105108
function processConfiguredOptions(options) {
106-
if(typeof options !== "object" || options === null) {
109+
if(options === null || typeof options !== "object") {
107110
console.error("Config did not export an object or a function returning an object.");
108111
process.exit(-1); // eslint-disable-line
109112
}

0 commit comments

Comments
 (0)