Skip to content

Commit

Permalink
Amended the error messages for the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsManta committed Oct 23, 2018
1 parent e14f76f commit fc52ac2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions edge/commandLineProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ function process(command, params = [], Console = console) {
throw new Error('The given option file path did not exist.')
}

try {
const fileText = fs.readFileSync(optionFilePathParams[1], 'utf8')
if (optionFilePathParams[1].endsWith('.yaml') || optionFilePathParams[1].endsWith('.yml')) {
const fileText = fs.readFileSync(optionFilePathParams[1], 'utf8')
if (optionFilePathParams[1].endsWith('.yaml') || optionFilePathParams[1].endsWith('.yml')) {
try {
formattingOptions = YAML.safeLoad(fileText, { json: true })
} else {
} catch (ex) {
throw new Error('The given option file could not be parsed as JSON.')
}
} else {
try {
formattingOptions = JSON5.parse(fileText)
} catch (ex) {
throw new Error('The given option file could not be parsed as YAML.')
}
} catch (ex) {
throw new Error('The given option file could not be parsed as JSON.')
}

if (fp.basename(optionFilePathParams[1]).startsWith('.stylintrc')) {
Expand Down

0 comments on commit fc52ac2

Please sign in to comment.