Add debugging logs to JS-Beautify and Coffee-Fmt beautifiers
This commit is contained in:
parent
1fe0d002b8
commit
5d085f0f5c
|
@ -1,7 +1,7 @@
|
||||||
"use strict"
|
"use strict"
|
||||||
Beautifier = require('./beautifier')
|
Beautifier = require('./beautifier')
|
||||||
|
|
||||||
module.exports = class PrettyDiff extends Beautifier
|
module.exports = class CoffeeFmt extends Beautifier
|
||||||
name: "coffee-fmt"
|
name: "coffee-fmt"
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
|
@ -14,13 +14,17 @@ module.exports = class PrettyDiff extends Beautifier
|
||||||
}
|
}
|
||||||
|
|
||||||
beautify: (text, language, options) ->
|
beautify: (text, language, options) ->
|
||||||
|
@verbose('beautify', language, options)
|
||||||
return new @Promise((resolve, reject) ->
|
return new @Promise((resolve, reject) ->
|
||||||
# Add newLine option
|
# Add newLine option
|
||||||
options.newLine = "\n"
|
options.newLine = "\n"
|
||||||
# Require
|
# Require
|
||||||
fmt = require('coffee-fmt')
|
fmt = require('coffee-fmt')
|
||||||
# Format!
|
# Format!
|
||||||
|
try
|
||||||
results = fmt.format(text, options)
|
results = fmt.format(text, options)
|
||||||
# Return beautified CoffeeScript code
|
# Return beautified CoffeeScript code
|
||||||
resolve(results)
|
resolve(results)
|
||||||
|
catch e
|
||||||
|
reject(e)
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,8 +15,8 @@ module.exports = class JSBeautify extends Beautifier
|
||||||
}
|
}
|
||||||
|
|
||||||
beautify: (text, language, options) ->
|
beautify: (text, language, options) ->
|
||||||
|
@verbose("JS Beautify language #{language}")
|
||||||
return new @Promise((resolve, reject) ->
|
return new @Promise((resolve, reject) =>
|
||||||
try
|
try
|
||||||
switch language
|
switch language
|
||||||
when "JSON", "JavaScript"
|
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#)"
|
when "HTML (Liquid)", "HTML", "XML", "Marko", "Web Form/Control (C#)", "Web Handler (C#)"
|
||||||
beautifyHTML = require("js-beautify").html
|
beautifyHTML = require("js-beautify").html
|
||||||
text = beautifyHTML(text, options)
|
text = beautifyHTML(text, options)
|
||||||
|
@debug("Beautified HTML: #{text}")
|
||||||
resolve text
|
resolve text
|
||||||
when "CSS"
|
when "CSS"
|
||||||
beautifyCSS = require("js-beautify").css
|
beautifyCSS = require("js-beautify").css
|
||||||
text = beautifyCSS(text, options)
|
text = beautifyCSS(text, options)
|
||||||
resolve text
|
resolve text
|
||||||
catch err
|
catch err
|
||||||
|
@error("JS Beautify error: #{err}")
|
||||||
reject(err)
|
reject(err)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,7 +43,7 @@ setCursors = (editor, posArray) ->
|
||||||
editor.addCursorAtBufferPosition bufferPosition
|
editor.addCursorAtBufferPosition bufferPosition
|
||||||
return
|
return
|
||||||
beautify = ({onSave}) ->
|
beautify = ({onSave}) ->
|
||||||
|
console.log('beautify!!!')
|
||||||
# Deprecation warning for beautify on save
|
# Deprecation warning for beautify on save
|
||||||
if atom.config.get("atom-beautify.beautifyOnSave") is true
|
if atom.config.get("atom-beautify.beautifyOnSave") is true
|
||||||
detail = """See issue https://github.com/Glavin001/atom-beautify/issues/308
|
detail = """See issue https://github.com/Glavin001/atom-beautify/issues/308
|
||||||
|
|
Loading…
Reference in New Issue