diff --git a/src/beautifiers/autopep8.coffee b/src/beautifiers/autopep8.coffee index 07fef6b..76bc3de 100644 --- a/src/beautifiers/autopep8.coffee +++ b/src/beautifiers/autopep8.coffee @@ -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? diff --git a/src/beautifiers/beautifier.coffee b/src/beautifiers/beautifier.coffee index 7d66e23..d39e51f 100644 --- a/src/beautifiers/beautifier.coffee +++ b/src/beautifiers/beautifier.coffee @@ -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 diff --git a/src/beautifiers/htmlbeautifier.coffee b/src/beautifiers/htmlbeautifier.coffee index 2c09341..6c439c4 100644 --- a/src/beautifiers/htmlbeautifier.coffee +++ b/src/beautifiers/htmlbeautifier.coffee @@ -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) '>' diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 4510f44..f9e1d61 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -67,7 +67,6 @@ module.exports = class Beautifiers Constructor ### constructor: -> - console.log(@) @beautifiers = _.map(@beautifierNames, (name) -> Beautifier = require("./#{name}") new Beautifier() diff --git a/src/beautifiers/js-beautify.coffee b/src/beautifiers/js-beautify.coffee index 87d3a3c..cd81d31 100644 --- a/src/beautifiers/js-beautify.coffee +++ b/src/beautifiers/js-beautify.coffee @@ -16,27 +16,28 @@ module.exports = class JSBeautify extends Beautifier beautify: (text, language, options) -> return new @Promise((resolve, reject) -> - console.log('JSBeautify', language, options) - - switch language - when "JSON", "JavaScript" - beautifyJS = require("js-beautify") - text = beautifyJS(text, options) - resolve text - when "Handlebars", "Mustache" - # jshint ignore: start - options.indent_handlebars = true # Force jsbeautify to indent_handlebars - # jshint ignore: end - beautifyHTML = require("js-beautify").html - text = beautifyHTML(text, options) - resolve text - when "HTML (Liquid)", "HTML", "XML", "Marko", "Web Form/Control (C#)", "Web Handler (C#)" - beautifyHTML = require("js-beautify").html - text = beautifyHTML(text, options) - resolve text - when "CSS" - beautifyCSS = require("js-beautify").css - text = beautifyCSS(text, options) - resolve text + try + switch language + when "JSON", "JavaScript" + beautifyJS = require("js-beautify") + text = beautifyJS(text, options) + resolve text + when "Handlebars", "Mustache" + # jshint ignore: start + options.indent_handlebars = true # Force jsbeautify to indent_handlebars + # jshint ignore: end + beautifyHTML = require("js-beautify").html + text = beautifyHTML(text, options) + resolve text + when "HTML (Liquid)", "HTML", "XML", "Marko", "Web Form/Control (C#)", "Web Handler (C#)" + beautifyHTML = require("js-beautify").html + text = beautifyHTML(text, options) + resolve text + when "CSS" + beautifyCSS = require("js-beautify").css + text = beautifyCSS(text, options) + resolve text + catch err + reject(err) ) diff --git a/src/beautifiers/perltidy.coffee b/src/beautifiers/perltidy.coffee index 48abe73..5c62f5f 100644 --- a/src/beautifiers/perltidy.coffee +++ b/src/beautifiers/perltidy.coffee @@ -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' diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index 6aac3b9..c602036 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -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) diff --git a/src/beautifiers/prettydiff.coffee b/src/beautifiers/prettydiff.coffee index 960020a..d5b40e5 100644 --- a/src/beautifiers/prettydiff.coffee +++ b/src/beautifiers/prettydiff.coffee @@ -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) diff --git a/src/beautifiers/ruby-beautify.coffee b/src/beautifiers/ruby-beautify.coffee index 8e0fdec..78e1758 100644 --- a/src/beautifiers/ruby-beautify.coffee +++ b/src/beautifiers/ruby-beautify.coffee @@ -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) ]) diff --git a/src/beautifiers/sqlformat.coffee b/src/beautifiers/sqlformat.coffee index 520c88d..d0da0a9 100644 --- a/src/beautifiers/sqlformat.coffee +++ b/src/beautifiers/sqlformat.coffee @@ -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? diff --git a/src/beautifiers/uncrustify/index.coffee b/src/beautifiers/uncrustify/index.coffee index 49085d6..93d541c 100644 --- a/src/beautifiers/uncrustify/index.coffee +++ b/src/beautifiers/uncrustify/index.coffee @@ -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" diff --git a/src/languages/c-sharp.coffee b/src/languages/c-sharp.coffee index 4bf97f5..c266c7a 100644 --- a/src/languages/c-sharp.coffee +++ b/src/languages/c-sharp.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/c.coffee b/src/languages/c.coffee index 70a1444..914c39c 100644 --- a/src/languages/c.coffee +++ b/src/languages/c.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/coffeescript.coffee b/src/languages/coffeescript.coffee index a9a43c2..7abdf9d 100644 --- a/src/languages/coffeescript.coffee +++ b/src/languages/coffeescript.coffee @@ -18,9 +18,4 @@ module.exports = { "coffee" ] - ### - Selected beautifier - ### - beautifier: "JS Beautifier" - } \ No newline at end of file diff --git a/src/languages/cpp.coffee b/src/languages/cpp.coffee index a362cbe..5e742a1 100644 --- a/src/languages/cpp.coffee +++ b/src/languages/cpp.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/css.coffee b/src/languages/css.coffee index e0b533d..1cee7c6 100644 --- a/src/languages/css.coffee +++ b/src/languages/css.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/d.coffee b/src/languages/d.coffee index 199d7d7..dcf2d8a 100644 --- a/src/languages/d.coffee +++ b/src/languages/d.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/erb.coffee b/src/languages/erb.coffee index 69672a9..081dd07 100644 --- a/src/languages/erb.coffee +++ b/src/languages/erb.coffee @@ -19,9 +19,4 @@ module.exports = { options: [] - ### - Selected beautifier - ### - beautifier: "JS Beautifier" - } \ No newline at end of file diff --git a/src/languages/handlebars.coffee b/src/languages/handlebars.coffee index 077bbea..64aed27 100644 --- a/src/languages/handlebars.coffee +++ b/src/languages/handlebars.coffee @@ -20,9 +20,4 @@ module.exports = { options: [] - ### - Selected beautifier - ### - beautifier: "JS Beautifier" - } \ No newline at end of file diff --git a/src/languages/html.coffee b/src/languages/html.coffee index 158d3d3..681b715 100644 --- a/src/languages/html.coffee +++ b/src/languages/html.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/java.coffee b/src/languages/java.coffee index 7093cc2..bc73432 100644 --- a/src/languages/java.coffee +++ b/src/languages/java.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/javascript.coffee b/src/languages/javascript.coffee index 32e22ee..c224d3c 100644 --- a/src/languages/javascript.coffee +++ b/src/languages/javascript.coffee @@ -105,9 +105,4 @@ module.exports = { default: false description: "End output with newline" - ### - Selected beautifier - ### - beautifier: "JS Beautifier" - } \ No newline at end of file diff --git a/src/languages/json.coffee b/src/languages/json.coffee index bfdf865..a03bb2f 100644 --- a/src/languages/json.coffee +++ b/src/languages/json.coffee @@ -18,9 +18,4 @@ module.exports = { "json" ] - ### - Selected beautifier - ### - beautifier: "JS Beautifier" - } \ No newline at end of file diff --git a/src/languages/jsx.coffee b/src/languages/jsx.coffee index c299bbb..d4331d9 100644 --- a/src/languages/jsx.coffee +++ b/src/languages/jsx.coffee @@ -18,9 +18,4 @@ module.exports = { "jsx" ] - ### - Selected beautifier - ### - beautifier: "JS Beautifier" - } \ No newline at end of file diff --git a/src/languages/less.coffee b/src/languages/less.coffee index 59b8cd2..006e449 100644 --- a/src/languages/less.coffee +++ b/src/languages/less.coffee @@ -14,11 +14,8 @@ module.exports = { ### Supported extensions ### - extensions: [] - - ### - Selected beautifier - ### - beautifier: "PrettyDiff" + extensions: [ + 'less' + ] } \ No newline at end of file diff --git a/src/languages/markdown.coffee b/src/languages/markdown.coffee index 159a048..8ad4d49 100644 --- a/src/languages/markdown.coffee +++ b/src/languages/markdown.coffee @@ -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: [] } \ No newline at end of file diff --git a/src/languages/marko.coffee b/src/languages/marko.coffee index 5d4255e..6253e4d 100644 --- a/src/languages/marko.coffee +++ b/src/languages/marko.coffee @@ -20,9 +20,4 @@ module.exports = { options: [] - ### - Selected beautifier - ### - beautifier: "JS Beautifier" - } \ No newline at end of file diff --git a/src/languages/mustache.coffee b/src/languages/mustache.coffee index 580142e..4172f55 100644 --- a/src/languages/mustache.coffee +++ b/src/languages/mustache.coffee @@ -15,14 +15,9 @@ module.exports = { Supported extensions ### extensions: [ - "hbs" + "mustache" ] options: [] - ### - Selected beautifier - ### - beautifier: "JS Beautifier" - } \ No newline at end of file diff --git a/src/languages/objective-c.coffee b/src/languages/objective-c.coffee index 2132d4e..e4c3180 100644 --- a/src/languages/objective-c.coffee +++ b/src/languages/objective-c.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/pawn.coffee b/src/languages/pawn.coffee index 6db991c..054ccaf 100644 --- a/src/languages/pawn.coffee +++ b/src/languages/pawn.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/perl.coffee b/src/languages/perl.coffee index 352affd..162011c 100644 --- a/src/languages/perl.coffee +++ b/src/languages/perl.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/php.coffee b/src/languages/php.coffee index 6737d6c..560f5d8 100644 --- a/src/languages/php.coffee +++ b/src/languages/php.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/python.coffee b/src/languages/python.coffee index 5d2fc77..15ef939 100644 --- a/src/languages/python.coffee +++ b/src/languages/python.coffee @@ -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" - } \ No newline at end of file diff --git a/src/languages/ruby.coffee b/src/languages/ruby.coffee index 5885a87..13f3f1c 100644 --- a/src/languages/ruby.coffee +++ b/src/languages/ruby.coffee @@ -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: [] } \ No newline at end of file diff --git a/src/languages/sass.coffee b/src/languages/sass.coffee index 3b31ff1..ca96abe 100644 --- a/src/languages/sass.coffee +++ b/src/languages/sass.coffee @@ -18,9 +18,4 @@ module.exports = { "sass" ] - ### - Selected beautifier - ### - beautifier: "PrettyDiff" - } \ No newline at end of file diff --git a/src/languages/scss.coffee b/src/languages/scss.coffee index 7a1bbf6..d77dc62 100644 --- a/src/languages/scss.coffee +++ b/src/languages/scss.coffee @@ -18,9 +18,4 @@ module.exports = { "scss" ] - ### - Selected beautifier - ### - beautifier: "PrettyDiff" - } \ No newline at end of file diff --git a/src/languages/sql.coffee b/src/languages/sql.coffee index ba1a9b6..3808bed 100644 --- a/src/languages/sql.coffee +++ b/src/languages/sql.coffee @@ -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" } \ No newline at end of file diff --git a/src/languages/tss.coffee b/src/languages/tss.coffee index a4abb24..08bd704 100644 --- a/src/languages/tss.coffee +++ b/src/languages/tss.coffee @@ -15,11 +15,8 @@ module.exports = { ### Supported extensions ### - extensions: [] - - ### - Selected beautifier - ### - beautifier: "PrettyDiff" + extensions: [ + "tss" + ] } \ No newline at end of file diff --git a/src/languages/typescript.coffee b/src/languages/typescript.coffee index 646c371..3a0d28c 100644 --- a/src/languages/typescript.coffee +++ b/src/languages/typescript.coffee @@ -15,11 +15,7 @@ module.exports = { Supported extensions ### extensions: [ + "ts" ] - ### - Selected beautifier - ### - beautifier: "JS Beautifier" - } \ No newline at end of file diff --git a/src/languages/vala.coffee b/src/languages/vala.coffee index d18e087..36c5ba7 100644 --- a/src/languages/vala.coffee +++ b/src/languages/vala.coffee @@ -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" - } \ No newline at end of file