See #164. Remove CLI Path options for CLI beautifiers

CLI beautifiers no longer need hardcoded/fixed paths
to their executable, since the PATH and
other environment variables are being auto-detected
This commit is contained in:
Glavin Wiechert 2015-04-30 15:53:24 -03:00
parent 240368fb09
commit 1a92e608d5
40 changed files with 75 additions and 367 deletions

View File

@ -11,17 +11,8 @@ module.exports = class autopep8 extends Beautifier
Python: true Python: true
} }
cli: (options) ->
path = options.autopep8_path # jshint ignore: line
if path
# Use absolute path
"\"#{path}\""
else
# Use command available in $PATH
"autopep8"
beautify: (text, language, options) -> beautify: (text, language, options) ->
@run(@cli(options), [ @run("autopep8", [
@tempFile("input", text) @tempFile("input", text)
"--max-line-length #{options.max_line_length}" if options.max_line_length? "--max-line-length #{options.max_line_length}" if options.max_line_length?
"--indent-size #{options.indent_size}" if options.indent_size? "--indent-size #{options.indent_size}" if options.indent_size?

View File

@ -37,11 +37,6 @@ module.exports = class Beautifier
### ###
languages: null languages: null
###
Filter beautifier
###
filter: () ->
### ###
Show deprecation warning to user. Show deprecation warning to user.
@ -56,7 +51,7 @@ module.exports = class Beautifier
return new Promise((resolve, reject) -> return new Promise((resolve, reject) ->
# create temp file # create temp file
temp.open(name, (err, info) -> temp.open(name, (err, info) ->
console.log(name, err, info) # console.log(name, err, info)
return reject(err) if err return reject(err) if err
fs.write(info.fd, contents, (err) -> fs.write(info.fd, contents, (err) ->
return reject(err) if err return reject(err) if err

View File

@ -11,18 +11,8 @@ module.exports = class HTMLBeautifier extends Beautifier
ERB: true ERB: true
} }
cli: (options) ->
htmlBeautifierPath = options.htmlbeautifier_path # jshint ignore: line
#
if htmlBeautifierPath
# Use absolute path
htmlBeautifierPath
else
# Use command available in $PATH
"htmlbeautifier"
beautify: (text, language, options) -> beautify: (text, language, options) ->
@run(@cli(options), [ @run("htmlbeautifier", [
'<' '<'
@tempFile("input", text) @tempFile("input", text)
'>' '>'

View File

@ -67,7 +67,6 @@ module.exports = class Beautifiers
Constructor Constructor
### ###
constructor: -> constructor: ->
console.log(@)
@beautifiers = _.map(@beautifierNames, (name) -> @beautifiers = _.map(@beautifierNames, (name) ->
Beautifier = require("./#{name}") Beautifier = require("./#{name}")
new Beautifier() new Beautifier()

View File

@ -16,8 +16,7 @@ module.exports = class JSBeautify extends Beautifier
beautify: (text, language, options) -> beautify: (text, language, options) ->
return new @Promise((resolve, reject) -> return new @Promise((resolve, reject) ->
console.log('JSBeautify', language, options) try
switch language switch language
when "JSON", "JavaScript" when "JSON", "JavaScript"
beautifyJS = require("js-beautify") beautifyJS = require("js-beautify")
@ -38,5 +37,7 @@ module.exports = class JSBeautify extends Beautifier
beautifyCSS = require("js-beautify").css beautifyCSS = require("js-beautify").css
text = beautifyCSS(text, options) text = beautifyCSS(text, options)
resolve text resolve text
catch err
reject(err)
) )

View File

@ -18,7 +18,7 @@ module.exports = class PerlTidy extends Beautifier
return options.perltidy_path return options.perltidy_path
beautify: (text, language, options) -> beautify: (text, language, options) ->
@run(@cli(options), [ @run("perltidy", [
'--standard-output' '--standard-output'
'--standard-error-output' '--standard-error-output'
'--quiet' '--quiet'

View File

@ -11,25 +11,8 @@ module.exports = class PHPCSFixer extends Beautifier
PHP: true PHP: true
} }
cli: (options) ->
phpCsFixerPath = options.cs_fixer_path # jshint ignore: line
if phpCsFixerPath
isWin = /^win/.test(process.platform)
# Use absolute path
if isWin
# Windows does require `php` prefix
# See https://github.com/Glavin001/atom-beautify/issues/269
"php \"#{phpCsFixerPath}\""
else
# Mac & Linux do not require `php` prefix
# See https://github.com/Glavin001/atom-beautify/pull/263
"\"#{phpCsFixerPath}\""
else
# Use command available in $PATH
"php-cs-fixer"
beautify: (text, language, options) -> beautify: (text, language, options) ->
@run(@cli(options), [ @run("php-cs-fixer", [
"--level=#{options.level}" if options.level? "--level=#{options.level}" if options.level?
"--fixers=#{options.fixers}" if options.fixers? "--fixers=#{options.fixers}" if options.fixers?
tempFile = @tempFile("temp", text) tempFile = @tempFile("temp", text)

View File

@ -92,7 +92,6 @@ module.exports = class PrettyDiff extends Beautifier
# Merge args intos options # Merge args intos options
_.merge(options, args) _.merge(options, args)
console.log('prettydiff args', args, options)
# Beautify # Beautify
output = prettydiff.api(options) output = prettydiff.api(options)

View File

@ -11,16 +11,7 @@ module.exports = class RubyBeautify extends Beautifier
Ruby: true Ruby: true
} }
cli: (options) ->
path = options.rbeautify_path # jshint ignore: line
if path
# Use absolute path
"ruby \"#{path}\""
else
# Use command available in $PATH
"rbeautify"
beautify: (text, language, options) -> beautify: (text, language, options) ->
@run(@cli(options), [ @run("rbeautify", [
@tempFile("input", text) @tempFile("input", text)
]) ])

View File

@ -11,17 +11,8 @@ module.exports = class sqlformat extends Beautifier
SQL: true SQL: true
} }
cli: (options) ->
path = options.sqlformat_path
if path
# Use absolute path
"python \"#{path}\""
else
# Use command available in $PATH
"sqlformat"
beautify: (text, language, options) -> beautify: (text, language, options) ->
@run(@cli(options), [ @run("sqlformat", [
@tempFile("input", text) @tempFile("input", text)
"--reindent" "--reindent"
"--indent_width=#{options.indent_size}" if options.indent_size? "--indent_width=#{options.indent_size}" if options.indent_size?

View File

@ -21,17 +21,8 @@ module.exports = class Uncrustify extends Beautifier
Java: true Java: true
} }
cli: (options) ->
uncrustifyPath = options.uncrustifyPath
if uncrustifyPath
# Use path given by user
"\"#{uncrustifyPath}\""
else
# Use command available in $PATH
"uncrustify"
beautify: (text, language, options) -> beautify: (text, language, options) ->
console.log('uncrustify.beautify', language, options) # console.log('uncrustify.beautify', language, options)
return new @Promise((resolve, reject) => return new @Promise((resolve, reject) =>
configPath = options.configPath configPath = options.configPath
unless configPath unless configPath
@ -75,7 +66,7 @@ module.exports = class Uncrustify extends Beautifier
when "Java" when "Java"
lang = "JAVA" lang = "JAVA"
@run(@cli(options), [ @run("uncrustify", [
"-c" "-c"
configPath configPath
"-f" "-f"

View File

@ -19,21 +19,10 @@ module.exports = {
] ]
options: options:
# C# configPath:
cs_uncrustifyPath:
title: "C# Uncrustify Path"
type: 'string'
default: ""
description: "Path to the `uncrustify` CLI executable"
cs_configPath:
title: "C# Config Path" title: "C# Config Path"
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -18,19 +18,9 @@ module.exports = {
] ]
options: options:
# C configPath:
c_uncrustifyPath:
type: 'string'
default: ""
description: "Path to the `uncrustify` CLI executable"
c_configPath:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -18,9 +18,4 @@ module.exports = {
"coffee" "coffee"
] ]
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -15,26 +15,22 @@ module.exports = {
### ###
extensions: [ extensions: [
"h" "h"
"hh"
"cc"
"cpp" "cpp"
"cxx"
"C"
"c++"
"hpp"
"hxx"
"h++"
] ]
options: options:
# C++ configPath:
cpp_uncrustifyPath:
title: "C++ Uncrustify Path"
type: 'string'
default: ""
description: "Path to the `uncrustify` CLI executable"
cpp_configPath:
title: "C++ Config Path" title: "C++ Config Path"
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -51,10 +51,4 @@ module.exports = {
"Retain empty lines. "+ "Retain empty lines. "+
"Consecutive empty lines will be converted to a single empty line." "Consecutive empty lines will be converted to a single empty line."
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -17,21 +17,9 @@ module.exports = {
] ]
options: options:
# D configPath:
d_uncrustifyPath:
type: 'string'
default: ""
description: "Path to the `uncrustify` CLI executable"
d_configPath:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -19,9 +19,4 @@ module.exports = {
options: [] options: []
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -20,9 +20,4 @@ module.exports = {
options: [] options: []
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -25,12 +25,6 @@ module.exports = {
] ]
options: options:
# HTML
htmlbeautifier_path:
title: "htmlbeautifier path"
type: 'string'
default: ""
description: "Path to the `htmlbeautifier` CLI executable"
indent_inner_html: indent_inner_html:
type: 'boolean' type: 'boolean'
default: false default: false
@ -88,10 +82,4 @@ module.exports = {
default: false default: false
description: "End output with newline" description: "End output with newline"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -18,19 +18,9 @@ module.exports = {
] ]
options: options:
# Java configPath:
java_uncrustifyPath:
type: 'string'
default: ""
description: "Path to the `uncrustify` CLI executable"
java_configPath:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -105,9 +105,4 @@ module.exports = {
default: false default: false
description: "End output with newline" description: "End output with newline"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -18,9 +18,4 @@ module.exports = {
"json" "json"
] ]
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -18,9 +18,4 @@ module.exports = {
"jsx" "jsx"
] ]
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -14,11 +14,8 @@ module.exports = {
### ###
Supported extensions Supported extensions
### ###
extensions: [] extensions: [
'less'
### ]
Selected beautifier
###
beautifier: "PrettyDiff"
} }

View File

@ -18,21 +18,6 @@ module.exports = {
"md" "md"
] ]
options: options: []
# Markdown
markdown_pandoc_path:
type: 'string'
default: ""
description: "Path to the `pandoc` CLI executable"
markdown_yaml_front_matter:
type: 'boolean'
default: true
description: "Should also format YAML Front Matter (Jekyll) in Markdown"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -20,9 +20,4 @@ module.exports = {
options: [] options: []
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -15,14 +15,9 @@ module.exports = {
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"hbs" "mustache"
] ]
options: [] options: []
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -16,27 +16,16 @@ module.exports = {
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"m"
"mm"
"h"
] ]
options: options:
# Objective-C configPath:
objectivec_uncrustifyPath:
title: "Objective-C Uncrustify Path"
type: 'string'
default: ""
description: "Path to the `uncrustify` CLI executable"
objectivec_configPath:
title: "Objective-C Config Path" title: "Objective-C Config Path"
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -16,21 +16,9 @@ module.exports = {
extensions: [] extensions: []
options: options:
# Pawn configPath:
pawn_uncrustifyPath:
type: 'string'
default: ""
description: "Path to the `uncrustify` CLI executable"
pawn_configPath:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -14,23 +14,13 @@ module.exports = {
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"pl"
] ]
options: options:
# Perl perltidy_profile:
perl_perltidy_path:
type: 'string'
default: "perltidy"
description: "Path to the `perltidy` CLI executable"
perl_perltidy_profile:
type: 'string' type: 'string'
default: "" default: ""
description: "Specify a configuration file which will override the default name of .perltidyrc" description: "Specify a configuration file which will override the default name of .perltidyrc"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -18,23 +18,13 @@ module.exports = {
] ]
options: options:
# PHP fixers:
php_cs_fixer_path:
type: 'string'
default: ""
description: "Path to the `php-cs-fixer` CLI executable"
php_fixers:
type: 'string' type: 'string'
default: "" default: ""
description: "Add fixer(s). i.e. linefeed,-short_tag,indentation" description: "Add fixer(s). i.e. linefeed,-short_tag,indentation"
php_level: level:
type: 'string' type: 'string'
default: "" default: ""
description: "By default, all PSR-2 fixers and some additional ones are run." description: "By default, all PSR-2 fixers and some additional ones are run."
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -25,31 +25,20 @@ module.exports = {
] ]
options: options:
# Python max_line_length:
python_autopep8_path:
type: 'string'
default: ""
description: "Path to the `autopep8` CLI executable"
python_max_line_length:
type: 'integer' type: 'integer'
default: 79 default: 79
description: "set maximum allowed line length" description: "set maximum allowed line length"
python_indent_size: indent_size:
type: 'integer' type: 'integer'
default: defaultIndentSize default: defaultIndentSize
minimum: 0 minimum: 0
description: "Indentation size/length" description: "Indentation size/length"
python_ignore: ignore:
type: 'array' type: 'array'
default: ["E24"] default: ["E24"]
items: items:
type: 'string' type: 'string'
description: "do not fix these errors/warnings" description: "do not fix these errors/warnings"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -14,19 +14,10 @@ module.exports = {
### ###
Supported extensions Supported extensions
### ###
extensions: [] extensions: [
"rb"
]
options: options: []
# Ruby
ruby_rbeautify_path:
type: 'string'
default: ""
description: "Path to the `rbeautify` CLI executable"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -18,9 +18,4 @@ module.exports = {
"sass" "sass"
] ]
###
Selected beautifier
###
beautifier: "PrettyDiff"
} }

View File

@ -18,9 +18,4 @@ module.exports = {
"scss" "scss"
] ]
###
Selected beautifier
###
beautifier: "PrettyDiff"
} }

View File

@ -42,16 +42,5 @@ module.exports = {
default: "lower" default: "lower"
description: "Change case of identifiers" description: "Change case of identifiers"
enum: ["lower","upper","capitalize"] enum: ["lower","upper","capitalize"]
sqlformat_path:
type: 'string'
default: ""
description: "Path to the `sqlformat` CLI executable"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -15,11 +15,8 @@ module.exports = {
### ###
Supported extensions Supported extensions
### ###
extensions: [] extensions: [
"tss"
### ]
Selected beautifier
###
beautifier: "PrettyDiff"
} }

View File

@ -15,11 +15,7 @@ module.exports = {
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"ts"
] ]
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }

View File

@ -13,24 +13,15 @@ module.exports = {
### ###
Supported extensions Supported extensions
### ###
extensions: [] extensions: [
"vala"
"vapi"
]
options: options:
# VALA configPath:
vala_uncrustifyPath:
type: 'string'
default: ""
description: "Path to the `uncrustify` CLI executable"
vala_configPath:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
###
Selected beautifier
###
beautifier: "JS Beautifier"
} }