Merge pull request #1127 from emileber/json-warning
Added notification for both YAML and JSON .jsbeautifyrc parse error
This commit is contained in:
commit
94fc58dc5d
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue