Closes #105. Add options to mute errors.
New options: - muteUnsupportedLanguageErrors - muteAllErrors
This commit is contained in:
parent
cd3656501c
commit
79fcdd9111
17
README.md
17
README.md
|
@ -85,10 +85,23 @@ For example:
|
|||
|
||||
### Package Options
|
||||
|
||||
- `beautifyOnSave`
|
||||
- `beautifyOnSave` (Default *false*)
|
||||
You can also choose to beautify on every file save.
|
||||
|
||||
- `analytics`
|
||||
- `beautifyEntireFileOnSave` (Default *true*)
|
||||
Beautification will normally only beautify your selected text.
|
||||
However, when beautification occurs on save then it will
|
||||
be forced to beautify the entire file's contents,
|
||||
not just selected text.
|
||||
|
||||
- `muteUnsupportedLanguageErrors` (Default *false*)
|
||||
Mute only *unsupported language* errors.
|
||||
|
||||
- `muteAllErrors` (Default *false*)
|
||||
Do not show the *Atom Beautify Error Messages* panel
|
||||
for any of the errors occurring while beautifying.
|
||||
|
||||
- `analytics` (Default *true*)
|
||||
There is [Segment.io](https://segment.io/),
|
||||
which forwards the data to [Google Analytics](http://www.google.com/analytics/),
|
||||
to track what languages
|
||||
|
|
|
@ -136,13 +136,14 @@ beautify = ->
|
|||
forceEntireFile = atom.config.get("atom-beautify.beautifyEntireFileOnSave")
|
||||
# Show error
|
||||
showError = (e) =>
|
||||
# console.log(e)
|
||||
@loadingView.hide()
|
||||
@messagePanel.attach()
|
||||
@messagePanel.add(new PlainMessageView({
|
||||
message: e.message,
|
||||
className: 'text-error'
|
||||
}))
|
||||
if not atom.config.get("atom-beautify.muteAllErrors")
|
||||
# console.log(e)
|
||||
@messagePanel.attach()
|
||||
@messagePanel.add(new PlainMessageView({
|
||||
message: e.message,
|
||||
className: 'text-error'
|
||||
}))
|
||||
# Look for .jsbeautifierrc in file and home path, check env variables
|
||||
getConfig = (startPath, upwards=true) ->
|
||||
# Verify that startPath is a string
|
||||
|
@ -185,7 +186,9 @@ beautify = ->
|
|||
# Asynchronously and callback-style
|
||||
beautifyCompleted = (text) =>
|
||||
# console.log 'beautifyCompleted'
|
||||
if text instanceof Error
|
||||
if not text?
|
||||
# Do nothing, is undefined
|
||||
else if text instanceof Error
|
||||
showError(text)
|
||||
else if oldText isnt text
|
||||
# console.log "Replacing current editor's text with new text"
|
||||
|
@ -313,6 +316,8 @@ plugin.configDefaults = _.merge(
|
|||
analytics: true
|
||||
beautifyOnSave: false
|
||||
beautifyEntireFileOnSave: true
|
||||
muteUnsupportedLanguageErrors: false
|
||||
muteAllErrors: false
|
||||
, defaultLanguageOptions)
|
||||
plugin.activate = ->
|
||||
handleSaveEvent()
|
||||
|
|
|
@ -88,7 +88,7 @@ module.exports =
|
|||
sql_keywords: "upper"
|
||||
sql_identifiers: "lower"
|
||||
sql_sqlformat_path: ""
|
||||
|
||||
|
||||
# Markdown
|
||||
markdown_pandoc_path: ""
|
||||
|
||||
|
@ -252,7 +252,10 @@ module.exports =
|
|||
category: version
|
||||
#
|
||||
if unsupportedGrammar
|
||||
throw new Error("Unsupported language for grammar '#{grammar}'.")
|
||||
if atom.config.get("atom-beautify.muteUnsupportedLanguageErrors")
|
||||
return beautifyCompleted(null)
|
||||
else
|
||||
throw new Error("Unsupported language for grammar '#{grammar}'.")
|
||||
return
|
||||
|
||||
getOptions: (selection, allOptions) ->
|
||||
|
|
Loading…
Reference in New Issue