From dc5f4a20dcef83ab457a6c1e76a2a7ba1c5a5b4a Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sun, 4 Jun 2017 02:43:02 -0300 Subject: [PATCH] Switch elm-format to using Executables --- docs/options.md | 17 +++++ .../nested-jsbeautifyrc/elm/expected/test.elm | 6 +- script/build-options.js | 4 +- src/beautifiers/elm-format.coffee | 28 +++++--- src/options.json | 64 ++++++++++++------- 5 files changed, 81 insertions(+), 38 deletions(-) diff --git a/docs/options.md b/docs/options.md index 1d96ef2..35cfbb8 100644 --- a/docs/options.md +++ b/docs/options.md @@ -232,6 +232,23 @@ Options for Dfmt executable. 2. Go into *Packages* and search for "*Atom Beautify*" package. 3. Find the option "*Dfmt*" and change it to your desired configuration. +##### [elm-format](#elm-format) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `object` + +**Description**: + +Options for elm-format executable. + +**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 "*elm-format*" and change it to your desired configuration. + ##### [Emacs](#emacs) **Important**: This option is only configurable from within Atom Beautify's setting panel. diff --git a/examples/nested-jsbeautifyrc/elm/expected/test.elm b/examples/nested-jsbeautifyrc/elm/expected/test.elm index 3280f99..0d13064 100644 --- a/examples/nested-jsbeautifyrc/elm/expected/test.elm +++ b/examples/nested-jsbeautifyrc/elm/expected/test.elm @@ -1,9 +1,9 @@ -module Main (..) where +module Main exposing (..) addThings x y = - x + y + x + y main = - addThings 4 5 + addThings 4 5 diff --git a/script/build-options.js b/script/build-options.js index 77c92b8..838d603 100644 --- a/script/build-options.js +++ b/script/build-options.js @@ -196,10 +196,10 @@ buildOptionsForExecutables = function(beautifiers) { properties: { path: { key: "path", - title: "Executable Path", + title: "Binary/Script Path", type: "string", default: "", - description: `Absolute path to the "${cmd}" executable.`, + description: `Absolute path to the "${cmd}" executable's binary/script.`, } } } diff --git a/src/beautifiers/elm-format.coffee b/src/beautifiers/elm-format.coffee index af91cf5..f6c8d85 100644 --- a/src/beautifiers/elm-format.coffee +++ b/src/beautifiers/elm-format.coffee @@ -7,7 +7,18 @@ Beautifier = require('./beautifier') module.exports = class ElmFormat extends Beautifier name: "elm-format" link: "https://github.com/avh4/elm-format" - isPreInstalled: false + executables: [ + { + name: "elm-format" + cmd: "elm-format" + homepage: "https://github.com/avh4/elm-format" + installation: "https://github.com/avh4/elm-format#installation-" + version: { + args: ['--help'] + parse: (text) -> text.match(/elm-format-\d+.\d+ (\d+\.\d+\.\d+)/)[1] + } + } + ] options: { Elm: true @@ -16,11 +27,10 @@ module.exports = class ElmFormat extends Beautifier beautify: (text, language, options) -> tempfile = @tempFile("input", text, ".elm") .then (name) => - @run("elm-format", [ - '--yes', - name - ], - { help: { link: 'https://github.com/avh4/elm-format#installation-' } } - ) - .then () => - @readFile(name) + @exe("elm-format") + .run([ + '--yes', + name + ]) + .then () => + @readFile(name) diff --git a/src/options.json b/src/options.json index 74637a6..4f4b65f 100644 --- a/src/options.json +++ b/src/options.json @@ -9139,10 +9139,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"uncrustify\" executable." + "description": "Absolute path to the \"uncrustify\" executable's binary/script." } } }, @@ -9155,10 +9155,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"autopep8\" executable." + "description": "Absolute path to the \"autopep8\" executable's binary/script." } } }, @@ -9171,10 +9171,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"isort\" executable." + "description": "Absolute path to the \"isort\" executable's binary/script." } } }, @@ -9187,10 +9187,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"clang-format\" executable." + "description": "Absolute path to the \"clang-format\" executable's binary/script." } } }, @@ -9203,10 +9203,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"crystal\" executable." + "description": "Absolute path to the \"crystal\" executable's binary/script." } } }, @@ -9219,10 +9219,26 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"dfmt\" executable." + "description": "Absolute path to the \"dfmt\" executable's binary/script." + } + } + }, + "elm-format": { + "key": "elm-format", + "title": "elm-format", + "type": "object", + "collapsed": true, + "description": "Options for elm-format executable.", + "properties": { + "path": { + "key": "path", + "title": "Binary/Script Path", + "type": "string", + "default": "", + "description": "Absolute path to the \"elm-format\" executable's binary/script." } } }, @@ -9235,10 +9251,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"emacs\" executable." + "description": "Absolute path to the \"emacs\" executable's binary/script." } } }, @@ -9251,10 +9267,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"php\" executable." + "description": "Absolute path to the \"php\" executable's binary/script." } } }, @@ -9267,10 +9283,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"php-cs-fixer\" executable." + "description": "Absolute path to the \"php-cs-fixer\" executable's binary/script." } } }, @@ -9283,10 +9299,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"phpcbf\" executable." + "description": "Absolute path to the \"phpcbf\" executable's binary/script." } } }, @@ -9299,10 +9315,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"Rscript\" executable." + "description": "Absolute path to the \"Rscript\" executable's binary/script." } } }, @@ -9315,10 +9331,10 @@ "properties": { "path": { "key": "path", - "title": "Executable Path", + "title": "Binary/Script Path", "type": "string", "default": "", - "description": "Absolute path to the \"beautysh\" executable." + "description": "Absolute path to the \"beautysh\" executable's binary/script." } } }