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:
parent
240368fb09
commit
1a92e608d5
|
@ -11,17 +11,8 @@ module.exports = class autopep8 extends Beautifier
|
|||
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) ->
|
||||
@run(@cli(options), [
|
||||
@run("autopep8", [
|
||||
@tempFile("input", text)
|
||||
"--max-line-length #{options.max_line_length}" if options.max_line_length?
|
||||
"--indent-size #{options.indent_size}" if options.indent_size?
|
||||
|
|
|
@ -37,11 +37,6 @@ module.exports = class Beautifier
|
|||
###
|
||||
languages: null
|
||||
|
||||
###
|
||||
Filter beautifier
|
||||
###
|
||||
filter: () ->
|
||||
|
||||
###
|
||||
Show deprecation warning to user.
|
||||
|
||||
|
@ -56,7 +51,7 @@ module.exports = class Beautifier
|
|||
return new Promise((resolve, reject) ->
|
||||
# create temp file
|
||||
temp.open(name, (err, info) ->
|
||||
console.log(name, err, info)
|
||||
# console.log(name, err, info)
|
||||
return reject(err) if err
|
||||
fs.write(info.fd, contents, (err) ->
|
||||
return reject(err) if err
|
||||
|
|
|
@ -11,18 +11,8 @@ module.exports = class HTMLBeautifier extends Beautifier
|
|||
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) ->
|
||||
@run(@cli(options), [
|
||||
@run("htmlbeautifier", [
|
||||
'<'
|
||||
@tempFile("input", text)
|
||||
'>'
|
||||
|
|
|
@ -67,7 +67,6 @@ module.exports = class Beautifiers
|
|||
Constructor
|
||||
###
|
||||
constructor: ->
|
||||
console.log(@)
|
||||
@beautifiers = _.map(@beautifierNames, (name) ->
|
||||
Beautifier = require("./#{name}")
|
||||
new Beautifier()
|
||||
|
|
|
@ -16,8 +16,7 @@ module.exports = class JSBeautify extends Beautifier
|
|||
beautify: (text, language, options) ->
|
||||
|
||||
return new @Promise((resolve, reject) ->
|
||||
console.log('JSBeautify', language, options)
|
||||
|
||||
try
|
||||
switch language
|
||||
when "JSON", "JavaScript"
|
||||
beautifyJS = require("js-beautify")
|
||||
|
@ -38,5 +37,7 @@ module.exports = class JSBeautify extends Beautifier
|
|||
beautifyCSS = require("js-beautify").css
|
||||
text = beautifyCSS(text, options)
|
||||
resolve text
|
||||
catch err
|
||||
reject(err)
|
||||
|
||||
)
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = class PerlTidy extends Beautifier
|
|||
return options.perltidy_path
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@run(@cli(options), [
|
||||
@run("perltidy", [
|
||||
'--standard-output'
|
||||
'--standard-error-output'
|
||||
'--quiet'
|
||||
|
|
|
@ -11,25 +11,8 @@ module.exports = class PHPCSFixer extends Beautifier
|
|||
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) ->
|
||||
@run(@cli(options), [
|
||||
@run("php-cs-fixer", [
|
||||
"--level=#{options.level}" if options.level?
|
||||
"--fixers=#{options.fixers}" if options.fixers?
|
||||
tempFile = @tempFile("temp", text)
|
||||
|
|
|
@ -92,7 +92,6 @@ module.exports = class PrettyDiff extends Beautifier
|
|||
|
||||
# Merge args intos options
|
||||
_.merge(options, args)
|
||||
console.log('prettydiff args', args, options)
|
||||
|
||||
# Beautify
|
||||
output = prettydiff.api(options)
|
||||
|
|
|
@ -11,16 +11,7 @@ module.exports = class RubyBeautify extends Beautifier
|
|||
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) ->
|
||||
@run(@cli(options), [
|
||||
@run("rbeautify", [
|
||||
@tempFile("input", text)
|
||||
])
|
||||
|
|
|
@ -11,17 +11,8 @@ module.exports = class sqlformat extends Beautifier
|
|||
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) ->
|
||||
@run(@cli(options), [
|
||||
@run("sqlformat", [
|
||||
@tempFile("input", text)
|
||||
"--reindent"
|
||||
"--indent_width=#{options.indent_size}" if options.indent_size?
|
||||
|
|
|
@ -21,17 +21,8 @@ module.exports = class Uncrustify extends Beautifier
|
|||
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) ->
|
||||
console.log('uncrustify.beautify', language, options)
|
||||
# console.log('uncrustify.beautify', language, options)
|
||||
return new @Promise((resolve, reject) =>
|
||||
configPath = options.configPath
|
||||
unless configPath
|
||||
|
@ -75,7 +66,7 @@ module.exports = class Uncrustify extends Beautifier
|
|||
when "Java"
|
||||
lang = "JAVA"
|
||||
|
||||
@run(@cli(options), [
|
||||
@run("uncrustify", [
|
||||
"-c"
|
||||
configPath
|
||||
"-f"
|
||||
|
|
|
@ -19,21 +19,10 @@ module.exports = {
|
|||
]
|
||||
|
||||
options:
|
||||
# C#
|
||||
cs_uncrustifyPath:
|
||||
title: "C# Uncrustify Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
cs_configPath:
|
||||
configPath:
|
||||
title: "C# Config Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -18,19 +18,9 @@ module.exports = {
|
|||
]
|
||||
|
||||
options:
|
||||
# C
|
||||
c_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
c_configPath:
|
||||
configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -18,9 +18,4 @@ module.exports = {
|
|||
"coffee"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -15,26 +15,22 @@ module.exports = {
|
|||
###
|
||||
extensions: [
|
||||
"h"
|
||||
"hh"
|
||||
"cc"
|
||||
"cpp"
|
||||
"cxx"
|
||||
"C"
|
||||
"c++"
|
||||
"hpp"
|
||||
"hxx"
|
||||
"h++"
|
||||
]
|
||||
|
||||
options:
|
||||
# C++
|
||||
cpp_uncrustifyPath:
|
||||
title: "C++ Uncrustify Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
cpp_configPath:
|
||||
configPath:
|
||||
title: "C++ Config Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -51,10 +51,4 @@ module.exports = {
|
|||
"Retain empty lines. "+
|
||||
"Consecutive empty lines will be converted to a single empty line."
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -17,21 +17,9 @@ module.exports = {
|
|||
]
|
||||
|
||||
options:
|
||||
# D
|
||||
d_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
d_configPath:
|
||||
configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -19,9 +19,4 @@ module.exports = {
|
|||
|
||||
options: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -20,9 +20,4 @@ module.exports = {
|
|||
|
||||
options: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -25,12 +25,6 @@ module.exports = {
|
|||
]
|
||||
|
||||
options:
|
||||
# HTML
|
||||
htmlbeautifier_path:
|
||||
title: "htmlbeautifier path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `htmlbeautifier` CLI executable"
|
||||
indent_inner_html:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
|
@ -88,10 +82,4 @@ module.exports = {
|
|||
default: false
|
||||
description: "End output with newline"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -18,19 +18,9 @@ module.exports = {
|
|||
]
|
||||
|
||||
options:
|
||||
# Java
|
||||
java_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
java_configPath:
|
||||
configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -105,9 +105,4 @@ module.exports = {
|
|||
default: false
|
||||
description: "End output with newline"
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -18,9 +18,4 @@ module.exports = {
|
|||
"json"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -18,9 +18,4 @@ module.exports = {
|
|||
"jsx"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -14,11 +14,8 @@ module.exports = {
|
|||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "PrettyDiff"
|
||||
extensions: [
|
||||
'less'
|
||||
]
|
||||
|
||||
}
|
|
@ -18,21 +18,6 @@ module.exports = {
|
|||
"md"
|
||||
]
|
||||
|
||||
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"
|
||||
options: []
|
||||
|
||||
}
|
|
@ -20,9 +20,4 @@ module.exports = {
|
|||
|
||||
options: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -15,14 +15,9 @@ module.exports = {
|
|||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"hbs"
|
||||
"mustache"
|
||||
]
|
||||
|
||||
options: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -16,27 +16,16 @@ module.exports = {
|
|||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
|
||||
"m"
|
||||
"mm"
|
||||
"h"
|
||||
]
|
||||
|
||||
options:
|
||||
# Objective-C
|
||||
objectivec_uncrustifyPath:
|
||||
title: "Objective-C Uncrustify Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
objectivec_configPath:
|
||||
configPath:
|
||||
title: "Objective-C Config Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -16,21 +16,9 @@ module.exports = {
|
|||
extensions: []
|
||||
|
||||
options:
|
||||
# Pawn
|
||||
pawn_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
pawn_configPath:
|
||||
configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -14,23 +14,13 @@ module.exports = {
|
|||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"pl"
|
||||
]
|
||||
|
||||
options:
|
||||
# Perl
|
||||
perl_perltidy_path:
|
||||
type: 'string'
|
||||
default: "perltidy"
|
||||
description: "Path to the `perltidy` CLI executable"
|
||||
perl_perltidy_profile:
|
||||
perltidy_profile:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Specify a configuration file which will override the default name of .perltidyrc"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -18,23 +18,13 @@ module.exports = {
|
|||
]
|
||||
|
||||
options:
|
||||
# PHP
|
||||
php_cs_fixer_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `php-cs-fixer` CLI executable"
|
||||
php_fixers:
|
||||
fixers:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Add fixer(s). i.e. linefeed,-short_tag,indentation"
|
||||
php_level:
|
||||
level:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "By default, all PSR-2 fixers and some additional ones are run."
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -25,31 +25,20 @@ module.exports = {
|
|||
]
|
||||
|
||||
options:
|
||||
# Python
|
||||
python_autopep8_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `autopep8` CLI executable"
|
||||
python_max_line_length:
|
||||
max_line_length:
|
||||
type: 'integer'
|
||||
default: 79
|
||||
description: "set maximum allowed line length"
|
||||
python_indent_size:
|
||||
indent_size:
|
||||
type: 'integer'
|
||||
default: defaultIndentSize
|
||||
minimum: 0
|
||||
description: "Indentation size/length"
|
||||
python_ignore:
|
||||
ignore:
|
||||
type: 'array'
|
||||
default: ["E24"]
|
||||
items:
|
||||
type: 'string'
|
||||
description: "do not fix these errors/warnings"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -14,19 +14,10 @@ module.exports = {
|
|||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: []
|
||||
extensions: [
|
||||
"rb"
|
||||
]
|
||||
|
||||
options:
|
||||
# Ruby
|
||||
ruby_rbeautify_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `rbeautify` CLI executable"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
options: []
|
||||
|
||||
}
|
|
@ -18,9 +18,4 @@ module.exports = {
|
|||
"sass"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "PrettyDiff"
|
||||
|
||||
}
|
|
@ -18,9 +18,4 @@ module.exports = {
|
|||
"scss"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "PrettyDiff"
|
||||
|
||||
}
|
|
@ -42,16 +42,5 @@ module.exports = {
|
|||
default: "lower"
|
||||
description: "Change case of identifiers"
|
||||
enum: ["lower","upper","capitalize"]
|
||||
sqlformat_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `sqlformat` CLI executable"
|
||||
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -15,11 +15,8 @@ module.exports = {
|
|||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "PrettyDiff"
|
||||
extensions: [
|
||||
"tss"
|
||||
]
|
||||
|
||||
}
|
|
@ -15,11 +15,7 @@ module.exports = {
|
|||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"ts"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -13,24 +13,15 @@ module.exports = {
|
|||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: []
|
||||
extensions: [
|
||||
"vala"
|
||||
"vapi"
|
||||
]
|
||||
|
||||
options:
|
||||
# VALA
|
||||
vala_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
vala_configPath:
|
||||
configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
Loading…
Reference in New Issue