diff --git a/CHANGELOG.md b/CHANGELOG.md index e55516b..5e7b4b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Closes [#776] (https://github.com/Glavin001/atom-beautify/issues/776) Add support for `collapse-preserve-inline` brace_style for javascript. - Closes [#786](https://github.com/Glavin001/atom-beautify/issues/786) YAPF configuration files are ignored. - Fix phpcbf hanging issue by closing stdin. See [#893](https://github.com/Glavin001/atom-beautify/issues/893) +- Add warning notification when parsing `.jsbeautifyrc` as JSON or YAML fails. See [#1106](https://github.com/Glavin001/atom-beautify/issues/1106) # v0.29.0 - Closes [#447](https://github.com/Glavin001/atom-beautify/issues/447). Improved Handlebars language support diff --git a/package.json b/package.json index 42443d8..c01fd59 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,10 @@ { "name": "Arman Yessenamanov", "url": "https://github.com/yesenarman" + }, + { + "name": "Émile Bergeron", + "url": "https://github.com/emileber" } ], "engines": { @@ -270,4 +274,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} \ No newline at end of file +} diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 94715dc..1e8bbc6 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -478,13 +478,23 @@ module.exports = class Beautifiers extends EventEmitter strip ?= require("strip-json-comments") externalOptions = JSON.parse(strip(contents)) catch e - + jsonError = e.message logger.debug "Failed parsing config as JSON: " + configPath # Attempt as YAML try yaml ?= require("yaml-front-matter") externalOptions = yaml.safeLoad(contents) catch e + title = "Atom Beautify failed to parse config as JSON or YAML" + detail = """ + Parsing '.jsbeautifyrc' at #{configPath} + JSON: #{jsonError} + YAML: #{e.message} + """ + atom?.notifications.addWarning(title, { + detail + dismissable : true + }) logger.debug "Failed parsing config as YAML and JSON: " + configPath externalOptions = {} else