diff --git a/examples/nested-jsbeautifyrc/python/original/_test.py b/examples/nested-jsbeautifyrc/python/original/test.py similarity index 100% rename from examples/nested-jsbeautifyrc/python/original/_test.py rename to examples/nested-jsbeautifyrc/python/original/test.py diff --git a/src/beautifiers/autopep8.coffee b/src/beautifiers/autopep8.coffee index 33ee14d..fe2e7b0 100644 --- a/src/beautifiers/autopep8.coffee +++ b/src/beautifiers/autopep8.coffee @@ -18,7 +18,7 @@ module.exports = class Autopep8 extends Beautifier version: { parse: (text) -> text.match(/autopep8 (\d+\.\d+\.\d+)/)[1] runOptions: { - returnStderr: true + returnStdoutOrStderr: true } } docker: { @@ -41,7 +41,7 @@ module.exports = class Autopep8 extends Beautifier Python: true } - beautify: (text, language, options) -> + beautify: (text, language, options, context = {}) -> @exe("autopep8").run([ tempFile = @tempFile("input", text) "-i" @@ -51,17 +51,8 @@ module.exports = class Autopep8 extends Beautifier ]) .then(=> if options.sort_imports - editor = atom.workspace.getActiveTextEditor() - filePath = editor.getPath() - projectPath = atom.project.relativizePath(filePath)[0] - - @exe("isort") - .run( - ["-sp", projectPath, tempFile], - ) - .then(=> - @readFile(tempFile) - ) - else - @readFile(tempFile) + filePath = context.filePath + projectPath = atom?.project.relativizePath(filePath)[0] + @exe("isort").run(["-sp", projectPath, tempFile]) ) + .then(=> @readFile(tempFile)) diff --git a/src/beautifiers/executable.coffee b/src/beautifiers/executable.coffee index 4afe944..b542601 100644 --- a/src/beautifiers/executable.coffee +++ b/src/beautifiers/executable.coffee @@ -129,7 +129,7 @@ class Executable ### run: (args, options = {}) -> @debug("Run: ", @cmd, args, options) - { cwd, ignoreReturnCode, help, onStdin, returnStderr } = options + { cwd, ignoreReturnCode, help, onStdin, returnStderr, returnStdoutOrStderr } = options exeName = @cmd config = @getConfig() cwd ?= os.tmpDir() @@ -179,7 +179,9 @@ class Executable else throw new Error(stderr or stdout) else - if returnStderr + if returnStdoutOrStderr + return stdout or stderr + else if returnStderr stderr else stdout