diff --git a/src/beautifiers/coffee-fmt.coffee b/src/beautifiers/coffee-fmt.coffee index 3fbc0e4..21129b8 100644 --- a/src/beautifiers/coffee-fmt.coffee +++ b/src/beautifiers/coffee-fmt.coffee @@ -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) ) diff --git a/src/beautifiers/js-beautify.coffee b/src/beautifiers/js-beautify.coffee index 19e2109..628db85 100644 --- a/src/beautifiers/js-beautify.coffee +++ b/src/beautifiers/js-beautify.coffee @@ -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) ) diff --git a/src/beautify.coffee b/src/beautify.coffee index a6c8f66..7134397 100644 --- a/src/beautify.coffee +++ b/src/beautify.coffee @@ -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