parent
803c35dfa4
commit
db5469b73e
|
@ -124,7 +124,7 @@
|
|||
"coffee-formatter": "^0.1.2",
|
||||
"coffee-script": "^1.10.0",
|
||||
"csscomb": "^3.1.7",
|
||||
"diff": "^3.0.0",
|
||||
"diff": "3.0.0",
|
||||
"editorconfig": "^0.13.2",
|
||||
"event-kit": "^2.1.0",
|
||||
"expand-home-dir": "0.0.3",
|
||||
|
|
|
@ -281,7 +281,7 @@ beautifyDirectory = ({target}) ->
|
|||
return
|
||||
|
||||
debug = () ->
|
||||
|
||||
try
|
||||
open = require("open")
|
||||
fs ?= require "fs"
|
||||
GitHubApi = require("github")
|
||||
|
@ -367,7 +367,7 @@ debug = () ->
|
|||
addInfo('Selected Beautifier', selectedBeautifier.name)
|
||||
|
||||
# Get current editor's text
|
||||
text = editor.getText()
|
||||
text = editor.getText() or ""
|
||||
|
||||
# Contents
|
||||
codeBlockSyntax = (language?.name ? grammarName).toLowerCase().split(' ')[0]
|
||||
|
@ -450,8 +450,9 @@ debug = () ->
|
|||
addInfo('Beautified File Contents', "\n```#{codeBlockSyntax}\n#{result}\n```")
|
||||
# Diff
|
||||
JsDiff = require('diff')
|
||||
diff = JsDiff.createPatch(filePath, text, \
|
||||
result, "original", "beautified")
|
||||
if typeof result is "string"
|
||||
diff = JsDiff.createPatch(filePath or "", text or "", \
|
||||
result or "", "original", "beautified")
|
||||
addInfo('Original vs. Beautified Diff', "\n```#{codeBlockSyntax}\n#{diff}\n```")
|
||||
|
||||
addHeader(3, "Logs")
|
||||
|
@ -514,6 +515,19 @@ debug = () ->
|
|||
catch e
|
||||
return cb(e)
|
||||
)
|
||||
.catch((error) ->
|
||||
stack = error.stack
|
||||
detail = error.description or error.message
|
||||
atom?.notifications?.addError(error.message, {
|
||||
stack, detail, dismissable : true
|
||||
})
|
||||
)
|
||||
catch error
|
||||
stack = error.stack
|
||||
detail = error.description or error.message
|
||||
atom?.notifications?.addError(error.message, {
|
||||
stack, detail, dismissable : true
|
||||
})
|
||||
|
||||
handleSaveEvent = ->
|
||||
atom.workspace.observeTextEditors (editor) ->
|
||||
|
|
Loading…
Reference in New Issue