Merge pull request #2069 from szeck87/rubocop-exe

Update Rubocop to be an executable
This commit is contained in:
Glavin Wiechert 2018-03-05 16:20:43 -04:00 committed by GitHub
commit 6bc36884eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 62 additions and 9 deletions

View File

@ -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/):<br/>1. Install [puppet-lint (`puppet-lint`)](http://puppet-lint.com/) with `docker pull unibeautify/puppet-lint`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [puppet-lint (`puppet-lint`)](http://puppet-lint.com/) by following http://puppet-lint.com/<br/> |
| 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:<br/>1. Install [Rubocop (`rubocop`)](http://rubocop.readthedocs.io/) by following http://rubocop.readthedocs.io/en/latest/installation/<br/> |
| 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/):<br/>1. Install [SassConvert (`sass-convert`)](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) with `docker pull unibeautify/sass-convert`<br/><br/>:bookmark_tabs: Manually:<br/>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<br/> |

View File

@ -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.

View File

@ -17,10 +17,26 @@ 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)
# 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
@ -48,14 +64,18 @@ module.exports = class Rubocop extends Beautifier
"--force-exclusion"
"--stdin", "atom-beautify.rb" # filename is required but not used
]
exeOptions = {
ignoreReturnCode: true,
cwd: projectPath if configFile?,
onStdin: (stdin) -> stdin.end text
}
rubocopArguments.push("--config", tempConfig) if tempConfig?
@debug("rubocop arguments", rubocopArguments)
@run(rubocopPath, rubocopArguments, {
ignoreReturnCode: true,
cwd: projectPath,
onStdin: (stdin) -> stdin.end text
}).then((stdout) =>
(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

View File

@ -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",