add eol support

This commit is contained in:
hxsf 2017-04-25 14:34:59 +08:00
parent 893e116fc4
commit 1e7b5cbe9f
2 changed files with 3 additions and 1 deletions

View File

@ -28,6 +28,7 @@ DEFAULT_WARN_FN = (msg) ->
module.exports = (str, indent, warn_fn, opts = {}) ->
do_not_change_whitespace = !!opts?.do_not_change_whitespace
eol = opts?.eol or '\n'
indent = indent or DEFAULT_INDENT
warn_fn = if typeof warn_fn == 'function' then warn_fn else DEFAULT_WARN_FN
indent = ' '.repeat(indent) if Number.isInteger(indent)
@ -102,4 +103,4 @@ module.exports = (str, indent, warn_fn, opts = {}) ->
new_line or undefined
warn_fn 'positive indentation at the end' if $currIndent > 0
new_code.join '\n'
new_code.join eol

View File

@ -16,6 +16,7 @@ module.exports = class Lua extends Beautifier
}
beautify: (text, language, options) ->
options.eol = @getDefaultLineEnding('\r\n','\n',options.end_of_line)
new @Promise (resolve, reject) ->
try
resolve format text, options.indent_char.repeat(options.indent_size), @warn, options