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: {
|
version: {
|
||||||
parse: (text) -> text.match(/autopep8 (\d+\.\d+\.\d+)/)[1]
|
parse: (text) -> text.match(/autopep8 (\d+\.\d+\.\d+)/)[1]
|
||||||
runOptions: {
|
runOptions: {
|
||||||
returnStderr: true
|
returnStdoutOrStderr: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
docker: {
|
docker: {
|
||||||
|
@ -41,7 +41,7 @@ module.exports = class Autopep8 extends Beautifier
|
||||||
Python: true
|
Python: true
|
||||||
}
|
}
|
||||||
|
|
||||||
beautify: (text, language, options) ->
|
beautify: (text, language, options, context = {}) ->
|
||||||
@exe("autopep8").run([
|
@exe("autopep8").run([
|
||||||
tempFile = @tempFile("input", text)
|
tempFile = @tempFile("input", text)
|
||||||
"-i"
|
"-i"
|
||||||
|
@ -51,17 +51,8 @@ module.exports = class Autopep8 extends Beautifier
|
||||||
])
|
])
|
||||||
.then(=>
|
.then(=>
|
||||||
if options.sort_imports
|
if options.sort_imports
|
||||||
editor = atom.workspace.getActiveTextEditor()
|
filePath = context.filePath
|
||||||
filePath = editor.getPath()
|
projectPath = atom?.project.relativizePath(filePath)[0]
|
||||||
projectPath = atom.project.relativizePath(filePath)[0]
|
@exe("isort").run(["-sp", projectPath, tempFile])
|
||||||
|
|
||||||
@exe("isort")
|
|
||||||
.run(
|
|
||||||
["-sp", projectPath, tempFile],
|
|
||||||
)
|
|
||||||
.then(=>
|
|
||||||
@readFile(tempFile)
|
|
||||||
)
|
|
||||||
else
|
|
||||||
@readFile(tempFile)
|
|
||||||
)
|
)
|
||||||
|
.then(=> @readFile(tempFile))
|
||||||
|
|
|
@ -129,7 +129,7 @@ class Executable
|
||||||
###
|
###
|
||||||
run: (args, options = {}) ->
|
run: (args, options = {}) ->
|
||||||
@debug("Run: ", @cmd, args, options)
|
@debug("Run: ", @cmd, args, options)
|
||||||
{ cwd, ignoreReturnCode, help, onStdin, returnStderr } = options
|
{ cwd, ignoreReturnCode, help, onStdin, returnStderr, returnStdoutOrStderr } = options
|
||||||
exeName = @cmd
|
exeName = @cmd
|
||||||
config = @getConfig()
|
config = @getConfig()
|
||||||
cwd ?= os.tmpDir()
|
cwd ?= os.tmpDir()
|
||||||
|
@ -179,7 +179,9 @@ class Executable
|
||||||
else
|
else
|
||||||
throw new Error(stderr or stdout)
|
throw new Error(stderr or stdout)
|
||||||
else
|
else
|
||||||
if returnStderr
|
if returnStdoutOrStderr
|
||||||
|
return stdout or stderr
|
||||||
|
else if returnStderr
|
||||||
stderr
|
stderr
|
||||||
else
|
else
|
||||||
stdout
|
stdout
|
||||||
|
|
Loading…
Reference in New Issue