Skip to content

Commit

Permalink
Closes #105. Add options to mute errors.
Browse files Browse the repository at this point in the history
New options:
- muteUnsupportedLanguageErrors
- muteAllErrors
  • Loading branch information
Glavin001 committed Sep 28, 2014
1 parent cd36565 commit 79fcdd9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 12 additions & 7 deletions lib/beautify.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -313,6 +316,8 @@ plugin.configDefaults = _.merge(
analytics: true
beautifyOnSave: false
beautifyEntireFileOnSave: true
muteUnsupportedLanguageErrors: false
muteAllErrors: false
, defaultLanguageOptions)
plugin.activate = ->
handleSaveEvent()
Expand Down
7 changes: 5 additions & 2 deletions lib/language-options.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module.exports =
sql_keywords: "upper"
sql_identifiers: "lower"
sql_sqlformat_path: ""

# Markdown
markdown_pandoc_path: ""

Expand Down Expand Up @@ -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) ->
Expand Down

0 comments on commit 79fcdd9

Please sign in to comment.