Add debugging logs to JS-Beautify and Coffee-Fmt beautifiers

This commit is contained in:
Glavin Wiechert 2015-05-18 16:58:52 -03:00
parent 1fe0d002b8
commit 5d085f0f5c
3 changed files with 14 additions and 8 deletions

View File

@ -1,7 +1,7 @@
"use strict"
Beautifier = require('./beautifier')
module.exports = class PrettyDiff extends Beautifier
module.exports = class CoffeeFmt extends Beautifier
name: "coffee-fmt"
options: {
@ -14,13 +14,17 @@ module.exports = class PrettyDiff extends Beautifier
}
beautify: (text, language, options) ->
@verbose('beautify', language, options)
return new @Promise((resolve, reject) ->
# Add newLine option
options.newLine = "\n"
# Require
fmt = require('coffee-fmt')
# Format!
results = fmt.format(text, options)
# Return beautified CoffeeScript code
resolve(results)
try
results = fmt.format(text, options)
# Return beautified CoffeeScript code
resolve(results)
catch e
reject(e)
)

View File

@ -3,7 +3,7 @@ Beautifier = require('./beautifier')
module.exports = class JSBeautify extends Beautifier
name: "JS Beautify"
options: {
HTML: true
Handlebars: true
@ -15,8 +15,8 @@ module.exports = class JSBeautify extends Beautifier
}
beautify: (text, language, options) ->
return new @Promise((resolve, reject) ->
@verbose("JS Beautify language #{language}")
return new @Promise((resolve, reject) =>
try
switch language
when "JSON", "JavaScript"
@ -33,12 +33,14 @@ module.exports = class JSBeautify extends Beautifier
when "HTML (Liquid)", "HTML", "XML", "Marko", "Web Form/Control (C#)", "Web Handler (C#)"
beautifyHTML = require("js-beautify").html
text = beautifyHTML(text, options)
@debug("Beautified HTML: #{text}")
resolve text
when "CSS"
beautifyCSS = require("js-beautify").css
text = beautifyCSS(text, options)
resolve text
catch err
@error("JS Beautify error: #{err}")
reject(err)
)

View File

@ -43,7 +43,7 @@ setCursors = (editor, posArray) ->
editor.addCursorAtBufferPosition bufferPosition
return
beautify = ({onSave}) ->
console.log('beautify!!!')
# Deprecation warning for beautify on save
if atom.config.get("atom-beautify.beautifyOnSave") is true
detail = """See issue https://github.com/Glavin001/atom-beautify/issues/308