Change the beautifier to conform to the expectations of elm-format

This commit is contained in:
Murphy Randle 2015-12-10 09:01:09 -07:00
parent 92fde28461
commit 2dcaba4f47
1 changed files with 15 additions and 4 deletions

View File

@ -1,9 +1,12 @@
###
Requires https://github.com/avh4/elm-format
###
"use strict"
Beautifier = require('./beautifier')
Promise = require("bluebird")
fs = require("fs")
readFile = Promise.promisify(fs.readFile)
rename = Promise.promisify(fs.rename)
module.exports = class ElmFormat extends Beautifier
name: "elm-format"
@ -13,6 +16,14 @@ module.exports = class ElmFormat extends Beautifier
}
beautify: (text, language, options) ->
tempfile = @tempFile("input", text)
.then (name) =>
newName = name + ".elm"
rename name, newName
.then () =>
@run("elm-format", [
@tempFile("input", text)
'--yes',
newName
])
.then () =>
readFile newName, {encoding: 'utf-8'}