Fix #1030. Autopep8 Executable did not handle older and newer versions
Older Autopep8 printed version to stderr, newer version to stdout. See https://github.com/Glavin001/atom-beautify/issues/1030#issuecomment-309318598
This commit is contained in:
parent
416e1abb27
commit
b83fdd5fe6
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue