Skip to content

Commit 4908a91

Browse files
jansensansindresorhus
authored andcommitted
Close #77 PR: Add error handling when config file missing.
1 parent 6bd9970 commit 4908a91

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ module.exports = function (options) {
2424
delete options.configPath;
2525

2626
if (configPath) {
27-
if (Object.keys(options).length) {
27+
if (typeof options === 'object' && Object.keys(options).length) {
2828
throw new Error('configPath option is not compatible with code style options');
2929
}
3030

31-
checker.configure(loadConfigFile.load(configPath));
31+
try {
32+
checker.configure(loadConfigFile.load(configPath));
33+
} catch (error) {
34+
throw new Error('Unable to load JSCS config file at ' + path.join(process.cwd(), configPath));
35+
}
3236
} else {
3337
checker.configure(options);
3438
}

0 commit comments

Comments
 (0)