Closes #945. Update TypeScript Formatter beautifier

This commit is contained in:
Glavin Wiechert 2016-04-23 23:24:55 -03:00
parent ef8ca9798b
commit 513ebd807c
4 changed files with 17 additions and 15 deletions

View File

@ -118,7 +118,8 @@
"strip-json-comments": "^1.0.2", "strip-json-comments": "^1.0.2",
"temp": "^0.8.3", "temp": "^0.8.3",
"tidy-markdown": "^2.0.1", "tidy-markdown": "^2.0.1",
"typescript-formatter": "~0.3.2", "typescript": "^1.8.10",
"typescript-formatter": "^2.1.0",
"underscore-plus": "^1.6.6", "underscore-plus": "^1.6.6",
"which": "^1.1.1", "which": "^1.1.1",
"winston": "^1.0.0", "winston": "^1.0.0",

View File

@ -10,8 +10,10 @@ module.exports = class TypeScriptFormatter extends Beautifier
beautify: (text, language, options) -> beautify: (text, language, options) ->
return new @Promise((resolve, reject) => return new @Promise((resolve, reject) =>
format = require("typescript-formatter/lib/formatter") try
format = require("typescript-formatter/lib/formatter").default
formatterUtils = require("typescript-formatter/lib/utils") formatterUtils = require("typescript-formatter/lib/utils")
# @verbose('format', format, formatterUtils)
opts = formatterUtils.createDefaultFormatCodeOptions() opts = formatterUtils.createDefaultFormatCodeOptions()
opts.TabSize = options.tab_width or options.indent_size opts.TabSize = options.tab_width or options.indent_size
@ -19,8 +21,7 @@ module.exports = class TypeScriptFormatter extends Beautifier
opts.IndentStyle = 'space' opts.IndentStyle = 'space'
opts.convertTabsToSpaces = true opts.convertTabsToSpaces = true
@verbose('typescript', text, opts) @verbose('typescript', text, opts)
try result = format('', text, opts)
result = format(text, opts)
@verbose(result) @verbose(result)
resolve result resolve result
catch e catch e