Change the beautifier to conform to the expectations of elm-format
This commit is contained in:
parent
92fde28461
commit
2dcaba4f47
|
@ -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'}
|
||||
|
|
Loading…
Reference in New Issue