Cleanup, address comments, and docs
This commit is contained in:
parent
1c20df5da6
commit
b85a2a9be7
|
@ -2467,6 +2467,61 @@ Automatically beautify EJS files on save
|
|||
2. Go into *Packages* and search for "*Atom Beautify*" package.
|
||||
3. Find the option "*Language Config - EJS - Beautify On Save*" and change it to your desired configuration.
|
||||
|
||||
#### [Language Config - Elm - Disable Beautifying Language](#language-config---elm---disable-beautifying-language)
|
||||
|
||||
**Important**: This option is only configurable from within Atom Beautify's setting panel.
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Description**:
|
||||
|
||||
Disable Elm Beautification
|
||||
|
||||
**How to Configure**
|
||||
|
||||
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
|
||||
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
|
||||
2. Go into *Packages* and search for "*Atom Beautify*" package.
|
||||
3. Find the option "*Language Config - Elm - Disable Beautifying Language*" and change it to your desired configuration.
|
||||
|
||||
#### [Language Config - Elm - Default Beautifier](#language-config---elm---default-beautifier)
|
||||
|
||||
**Important**: This option is only configurable from within Atom Beautify's setting panel.
|
||||
|
||||
**Default**: `elm-format`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `elm-format`
|
||||
|
||||
**Description**:
|
||||
|
||||
Default Beautifier to be used for Elm
|
||||
|
||||
**How to Configure**
|
||||
|
||||
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
|
||||
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
|
||||
2. Go into *Packages* and search for "*Atom Beautify*" package.
|
||||
3. Find the option "*Language Config - Elm - Default Beautifier*" and change it to your desired configuration.
|
||||
|
||||
#### [Language Config - Elm - Beautify On Save](#language-config---elm---beautify-on-save)
|
||||
|
||||
**Important**: This option is only configurable from within Atom Beautify's setting panel.
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Description**:
|
||||
|
||||
Automatically beautify Elm files on save
|
||||
|
||||
**How to Configure**
|
||||
|
||||
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
|
||||
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
|
||||
2. Go into *Packages* and search for "*Atom Beautify*" package.
|
||||
3. Find the option "*Language Config - Elm - Beautify On Save*" and change it to your desired configuration.
|
||||
|
||||
#### [Language Config - ERB - Disable Beautifying Language](#language-config---erb---disable-beautifying-language)
|
||||
|
||||
**Important**: This option is only configurable from within Atom Beautify's setting panel.
|
||||
|
|
|
@ -54,10 +54,10 @@ module.exports = class Beautifier
|
|||
###
|
||||
Create temporary file
|
||||
###
|
||||
tempFile: (name = "atom-beautify-temp", contents = "") ->
|
||||
tempFile: (name = "atom-beautify-temp", contents = "", ext = "") ->
|
||||
return new Promise((resolve, reject) =>
|
||||
# create temp file
|
||||
temp.open(name, (err, info) =>
|
||||
temp.open({prefix: name, suffix: ext}, (err, info) =>
|
||||
@debug('tempFile', name, err, info)
|
||||
return reject(err) if err
|
||||
fs.write(info.fd, contents, (err) ->
|
||||
|
|
|
@ -3,10 +3,6 @@ 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"
|
||||
|
@ -16,14 +12,13 @@ module.exports = class ElmFormat extends Beautifier
|
|||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
tempfile = @tempFile("input", text)
|
||||
tempfile = @tempFile("input", text, ".elm")
|
||||
.then (name) =>
|
||||
newName = name + ".elm"
|
||||
rename name, newName
|
||||
@run("elm-format", [
|
||||
'--yes',
|
||||
name
|
||||
],
|
||||
{ help: { link: 'https://github.com/avh4/elm-format' } }
|
||||
)
|
||||
.then () =>
|
||||
@run("elm-format", [
|
||||
'--yes',
|
||||
newName
|
||||
])
|
||||
.then () ->
|
||||
readFile newName, {encoding: 'utf-8'}
|
||||
@readFile(name)
|
||||
|
|
Loading…
Reference in New Issue