Skip to content

Commit

Permalink
Improve CLI Beautify class to handle more error catching
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed Dec 28, 2014
1 parent fd8c70e commit 60f6a9b
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions lib/langs/cli-beautify.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ module.exports = (getCmd, isStdout) ->

# Process the command
processCmd = (cmd) ->
if cmd
if typeof cmd is "string"

config = env: process.env
isWin = /^win/.test(process.platform)
unless isWin
Expand Down Expand Up @@ -68,20 +69,32 @@ module.exports = (getCmd, isStdout) ->
return

else
console.log "Beautifcation Error: ", err
console.error "Beautifcation Error: ", err
callback err
deleteOutputFile()
return

# Check if there's an error
else if cmd instanceof Error
return callback(cmd)
else
console.log "Beautify CLI command not valid."
callback(new Error("Beautify CLI command not valid."))
return
console.error "CLI Beautifier command not valid."
return callback(new Error("CLI Beautifier command not valid."+
" Invalid command '#{cmd}'."))


# Get the command
cmd = getCmd(info.path, outputPath, options, processCmd) # jshint ignore: line
processCmd cmd if typeof cmd is "string"
try
cmd = getCmd(info.path, outputPath, options, processCmd) # jshint ignore: line
catch e
return callback(e)

if typeof cmd is "string"
processCmd cmd
# Check if there's an error
else if cmd instanceof Error
return callback(cmd)

return

return
Expand Down

0 comments on commit 60f6a9b

Please sign in to comment.