From e6077cdbdbd714062c64f9cca575778fe194d3a1 Mon Sep 17 00:00:00 2001 From: Steven Zeck Date: Mon, 5 Mar 2018 12:19:39 -0600 Subject: [PATCH] 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