From 4ecd6682088e061615e72d52fcbe2b3e34c0c7a0 Mon Sep 17 00:00:00 2001 From: Steven Zeck Date: Mon, 5 Mar 2018 10:18:51 -0600 Subject: [PATCH 1/4] Update Rubocop to run as an exe --- .../ruby/original/{_test.rb => test.rb} | 0 src/beautifiers/rubocop.coffee | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) rename examples/nested-jsbeautifyrc/ruby/original/{_test.rb => test.rb} (100%) diff --git a/examples/nested-jsbeautifyrc/ruby/original/_test.rb b/examples/nested-jsbeautifyrc/ruby/original/test.rb similarity index 100% rename from examples/nested-jsbeautifyrc/ruby/original/_test.rb rename to examples/nested-jsbeautifyrc/ruby/original/test.rb diff --git a/src/beautifiers/rubocop.coffee b/src/beautifiers/rubocop.coffee index 138dfb5..fc7b222 100644 --- a/src/beautifiers/rubocop.coffee +++ b/src/beautifiers/rubocop.coffee @@ -17,6 +17,18 @@ module.exports = class Rubocop extends Beautifier rubocop_path: true } + executables: [ + { + name: "Rubocop" + cmd: "rubocop" + homepage: "http://rubocop.readthedocs.io/" + installation: "http://rubocop.readthedocs.io/en/latest/installation/" + version: { + parse: (text) -> text.match(/(\d+\.\d+\.\d+)/)[1] + } + } + ] + beautify: (text, language, options, context) -> fullPath = context.filePath or "" [projectPath, _relativePath] = atom.project.relativizePath(fullPath) @@ -51,9 +63,9 @@ module.exports = class Rubocop extends Beautifier rubocopArguments.push("--config", tempConfig) if tempConfig? @debug("rubocop arguments", rubocopArguments) - @run(rubocopPath, rubocopArguments, { + @exe("rubocop").run(rubocopArguments, { ignoreReturnCode: true, - cwd: projectPath, + cwd: projectPath if configFile?, onStdin: (stdin) -> stdin.end text }).then((stdout) => @debug("rubocop output", stdout) From dc500b6a05fba6d05c9970fe9f155c9f747b38f6 Mon Sep 17 00:00:00 2001 From: Steven Zeck Date: Mon, 5 Mar 2018 10:27:40 -0600 Subject: [PATCH 2/4] Fix Ruby test files --- examples/nested-jsbeautifyrc/ruby/expected/test.rb | 2 +- examples/nested-jsbeautifyrc/ruby/original/test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/nested-jsbeautifyrc/ruby/expected/test.rb b/examples/nested-jsbeautifyrc/ruby/expected/test.rb index 68a8bfe..402ab8a 100644 --- a/examples/nested-jsbeautifyrc/ruby/expected/test.rb +++ b/examples/nested-jsbeautifyrc/ruby/expected/test.rb @@ -15,6 +15,6 @@ hash = { hosts: [ ], - logger: mylog, # This enables callback logging! + logger: mylog, # This enables callback logging! max_reconnect_attempts: 5 } diff --git a/examples/nested-jsbeautifyrc/ruby/original/test.rb b/examples/nested-jsbeautifyrc/ruby/original/test.rb index f0b9442..b4d529e 100644 --- a/examples/nested-jsbeautifyrc/ruby/original/test.rb +++ b/examples/nested-jsbeautifyrc/ruby/original/test.rb @@ -18,7 +18,7 @@ hash = { :hosts => [ ], - :logger => mylog, # This enables callback logging! + :logger => mylog, # This enables callback logging! :max_reconnect_attempts => 5, From 919e19f4271f6529c89ba1574c9a810f4b905979 Mon Sep 17 00:00:00 2001 From: Steven Zeck Date: Mon, 5 Mar 2018 10:29:24 -0600 Subject: [PATCH 3/4] Run docs --- README.md | 2 +- docs/options.md | 17 +++++++++++++++++ package.json | 2 +- src/options.json | 16 ++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 721d956..eafa7dd 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall | puppet-lint | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):
1. Install [puppet-lint (`puppet-lint`)](http://puppet-lint.com/) with `docker pull unibeautify/puppet-lint`

:bookmark_tabs: Manually:
1. Install [puppet-lint (`puppet-lint`)](http://puppet-lint.com/) by following http://puppet-lint.com/
| | pybeautifier | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/guyskk/pybeautifier and follow the instructions. | | Remark | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | -| Rubocop | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/bbatsov/rubocop and follow the instructions. | +| Rubocop | :warning: 1 executable | :x: No Docker support | :bookmark_tabs: Manually:
1. Install [Rubocop (`rubocop`)](http://rubocop.readthedocs.io/) by following http://rubocop.readthedocs.io/en/latest/installation/
| | Ruby Beautify | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/erniebrodeur/ruby-beautify and follow the instructions. | | rustfmt | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/rust-lang-nursery/rustfmt and follow the instructions. | | SassConvert | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):
1. Install [SassConvert (`sass-convert`)](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) with `docker pull unibeautify/sass-convert`

:bookmark_tabs: Manually:
1. Install [SassConvert (`sass-convert`)](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) by following http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax
| diff --git a/docs/options.md b/docs/options.md index aea1173..5ceec35 100644 --- a/docs/options.md +++ b/docs/options.md @@ -402,6 +402,23 @@ Options for Rscript executable. 2. Go into *Packages* and search for "*Atom Beautify*" package. 3. Find the option "*Rscript*" and change it to your desired configuration. +##### [Rubocop](#rubocop) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `object` + +**Description**: + +Options for Rubocop 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 "*Rubocop*" and change it to your desired configuration. + ##### [SassConvert](#sassconvert) **Important**: This option is only configurable from within Atom Beautify's setting panel. diff --git a/package.json b/package.json index 58c380c..3271c63 100644 --- a/package.json +++ b/package.json @@ -483,4 +483,4 @@ "prettydiff2" ] } -} +} \ No newline at end of file diff --git a/src/options.json b/src/options.json index 9e1d59a..458cd8b 100644 --- a/src/options.json +++ b/src/options.json @@ -9278,6 +9278,22 @@ } } }, + "rubocop": { + "key": "rubocop", + "title": "Rubocop", + "type": "object", + "collapsed": true, + "description": "Options for Rubocop executable.", + "properties": { + "path": { + "key": "path", + "title": "Binary/Script Path", + "type": "string", + "default": "", + "description": "Absolute path to the \"rubocop\" executable's binary/script." + } + } + }, "sass-convert": { "key": "sass-convert", "title": "SassConvert", From e6077cdbdbd714062c64f9cca575778fe194d3a1 Mon Sep 17 00:00:00 2001 From: Steven Zeck Date: Mon, 5 Mar 2018 12:19:39 -0600 Subject: [PATCH 4/4] Deprecate options. rubocop_path, be backwards compatible with it --- src/beautifiers/rubocop.coffee | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/beautifiers/rubocop.coffee b/src/beautifiers/rubocop.coffee index fc7b222..b72f80d 100644 --- a/src/beautifiers/rubocop.coffee +++ b/src/beautifiers/rubocop.coffee @@ -33,6 +33,10 @@ module.exports = class Rubocop extends Beautifier fullPath = context.filePath or "" [projectPath, _relativePath] = atom.project.relativizePath(fullPath) + # Deprecate options.rubocop_path + if options.rubocop_path + @deprecateOptionForExecutable("Rubocop", "Ruby - Rubocop Path (rubocop_path)", "Path") + # Find the rubocop path @Promise.all([ @which(options.rubocop_path) if options.rubocop_path @@ -60,14 +64,18 @@ module.exports = class Rubocop extends Beautifier "--force-exclusion" "--stdin", "atom-beautify.rb" # filename is required but not used ] - rubocopArguments.push("--config", tempConfig) if tempConfig? - @debug("rubocop arguments", rubocopArguments) - - @exe("rubocop").run(rubocopArguments, { + exeOptions = { ignoreReturnCode: true, cwd: projectPath if configFile?, onStdin: (stdin) -> stdin.end text - }).then((stdout) => + } + rubocopArguments.push("--config", tempConfig) if tempConfig? + @debug("rubocop arguments", rubocopArguments) + + (if options.rubocop_path then \ + @run(rubocopPath, rubocopArguments, exeOptions) else \ + @exe("rubocop").run(rubocopArguments, exeOptions) + ).then((stdout) => @debug("rubocop output", stdout) # Rubocop output an error if stdout is empty return text if stdout.length == 0