Switch beautysh to using Executables

This commit is contained in:
Glavin Wiechert 2017-06-02 17:33:18 -03:00
parent d99b43cb16
commit 02d4c8f404
3 changed files with 20 additions and 10 deletions

View File

@ -407,6 +407,7 @@
"docs": "npm run build-options && coffee docs/",
"prepublish": "npm run docs",
"lint": "coffeelint src/ spec/",
"code-docs": "codo && open docs/code/index.html"
"code-docs": "codo && open docs/code/index.html",
"test": "atom --test spec"
}
}

View File

@ -45,9 +45,7 @@ module.exports = class Autopep8 extends Beautifier
["--max-line-length", "#{options.max_line_length}"] if options.max_line_length?
["--indent-size","#{options.indent_size}"] if options.indent_size?
["--ignore","#{options.ignore.join(',')}"] if options.ignore?
], help: {
link: "https://github.com/hhatto/autopep8"
})
])
.then(=>
if options.sort_imports
editor = atom.workspace.getActiveTextEditor()
@ -57,9 +55,7 @@ module.exports = class Autopep8 extends Beautifier
@exe("isort")
.run(
["-sp", projectPath, tempFile],
help: {
link: "https://github.com/timothycrosley/isort"
})
)
.then(=>
@readFile(tempFile)
)

View File

@ -4,7 +4,19 @@ Beautifier = require('./beautifier')
module.exports = class BashBeautify extends Beautifier
name: "beautysh"
link: "https://github.com/bemeurer/beautysh"
isPreInstalled: false
executables: [
{
name: "beautysh"
cmd: "beautysh"
homepage: "https://github.com/bemeurer/beautysh"
installation: "https://github.com/bemeurer/beautysh#installation"
version: {
# Does not display version
args: ['--help'],
parse: (text) -> text.indexOf("usage: beautysh") isnt -1 and "0.0.0"
}
}
]
options: {
Bash:
@ -12,6 +24,7 @@ module.exports = class BashBeautify extends Beautifier
}
beautify: (text, language, options) ->
beautysh = @exe("beautysh")
file = @tempFile("input", text)
@run('beautysh', [ '-i', options.indent_size, '-f', file ], help: { link: "https://github.com/bemeurer/beautysh" })
.then(=> @readFile file)
beautysh.run([ '-i', options.indent_size, '-f', file ])
.then(=> @readFile file)