Deprecate options. rubocop_path, be backwards compatible with it

This commit is contained in:
Steven Zeck 2018-03-05 12:19:39 -06:00
parent 919e19f427
commit e6077cdbdb
No known key found for this signature in database
GPG Key ID: 621B374B29AA814A
1 changed files with 13 additions and 5 deletions

View File

@ -33,6 +33,10 @@ module.exports = class Rubocop extends Beautifier
fullPath = context.filePath or "" fullPath = context.filePath or ""
[projectPath, _relativePath] = atom.project.relativizePath(fullPath) [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 # Find the rubocop path
@Promise.all([ @Promise.all([
@which(options.rubocop_path) if options.rubocop_path @which(options.rubocop_path) if options.rubocop_path
@ -60,14 +64,18 @@ module.exports = class Rubocop extends Beautifier
"--force-exclusion" "--force-exclusion"
"--stdin", "atom-beautify.rb" # filename is required but not used "--stdin", "atom-beautify.rb" # filename is required but not used
] ]
rubocopArguments.push("--config", tempConfig) if tempConfig? exeOptions = {
@debug("rubocop arguments", rubocopArguments)
@exe("rubocop").run(rubocopArguments, {
ignoreReturnCode: true, ignoreReturnCode: true,
cwd: projectPath if configFile?, cwd: projectPath if configFile?,
onStdin: (stdin) -> stdin.end text 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) @debug("rubocop output", stdout)
# Rubocop output an error if stdout is empty # Rubocop output an error if stdout is empty
return text if stdout.length == 0 return text if stdout.length == 0