diff --git a/src/cli.js b/src/cli.js index b83a5b6..96f0895 100755 --- a/src/cli.js +++ b/src/cli.js @@ -40,7 +40,7 @@ const yargv = yargs try { return util.configFile.readConfig(configPath) } catch (error) { - if (configPath !== defaultRCFile) { + if (error instanceof SyntaxError || configPath !== defaultRCFile) { onError(error) } } diff --git a/src/util/config-file.js b/src/util/config-file.js index 34bd561..661b5d0 100644 --- a/src/util/config-file.js +++ b/src/util/config-file.js @@ -10,6 +10,9 @@ function readConfig(configPath) { } return config } catch (error) { + if (error instanceof SyntaxError) { + throw new SyntaxError(`Configuration file has malformed JSON: ${configPath}. Error:: ${error.message}`) + } if (error.code === 'ENOENT') { throw new Error(`Configuration file not found: ${configPath}`) } @@ -24,7 +27,7 @@ function writeConfig(configPath, content) { if (!content.projectName) { throw new Error(`Error! Project name is not set in ${configPath}`) } - + if (content.files && !content.files.length) { throw new Error( `Error! Project files was overridden and is empty in ${configPath}`,