Add support for beautifiers ignoring CLI return code

Rubocop always returns an error code (1) instead of a good code (0) so
the beautifier has now been configured to ignore the return code / exit
status for only Rubocop beautifier. Other beautifiers will properly
return error when an bad return code is received.
This commit is contained in:
Glavin Wiechert 2015-05-03 12:22:24 -03:00
parent 65ef42fadb
commit 141bca7aba
2 changed files with 8 additions and 8 deletions

View File

@ -128,7 +128,7 @@ module.exports = class Beautifier
###
Run command-line interface command
###
run: (executable, args) ->
run: (executable, args, {ignoreReturnCode} = {}) ->
# Resolve executable
Promise.resolve(executable)
.then((exe) =>
@ -156,12 +156,12 @@ module.exports = class Beautifier
cmd.stdout.on('data', (data) -> stdout += data )
cmd.stderr.on('data', (data) -> stderr += data )
# when the spawn child process exits, check if there were any errors and close the writeable stream
cmd.on('exit', (code) ->
# console.log('spawn done', code, stderr, stdout)
cmd.on('exit', (returnCode) ->
console.log('spawn done', returnCode, stderr, stdout)
# If return code is not 0 then error occured
# if code isnt 0
# reject(stderr)
# else
if not ignoreReturnCode and returnCode isnt 0
reject(stderr)
else
resolve(stdout)
)
cmd.on('error', (err) ->

View File

@ -16,7 +16,7 @@ module.exports = class Rubocop extends Beautifier
@run("rubocop", [
"--auto-correct"
tempFile = @tempFile("temp", text)
])
], {ignoreReturnCode: true})
.then(=>
# console.log('rubocop', arguments, tempFile)
@readFile(tempFile)