Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

process.exit() with 0 or 1 depending on `err`

  • Loading branch information...
commit 0aaeabf2a5f81dc674d60004894d5fef557ed374 1 parent c176385
@rvagg rvagg authored
Showing with 8 additions and 5 deletions.
  1. +3 −1 bin/ender
  2. +5 −4 lib/main.js
View
4 bin/ender
@@ -1,3 +1,5 @@
#!/usr/bin/env node
-require('../lib/main').exec(process.argv)
+require('../lib/main').exec(process.argv, function (err) {
+ process.exit(err ? 1 : 0)
+})
View
9 lib/main.js
@@ -3,16 +3,17 @@ var sysUtil = require('util')
, Output = require('./output')
, EnderError = require('./errors').EnderError
- , complete = function (out, err) {
+ , complete = function (out, callback, err) {
if (err) {
if (err instanceof EnderError)
out.enderError(err)
else
out.unknownError(err)
}
+ callback(err)
}
- , exec = function (argv) {
+ , exec = function (argv, callback) {
try {
var args = argsParse.parse(argv)
, exe = args && require('./main-' + args.main)
@@ -20,10 +21,10 @@ var sysUtil = require('util')
if (exe && out) {
out.welcome()
- exe.exec(args, out, complete.bind(null, out))
+ exe.exec(args, out, complete.bind(null, out, callback))
} // else err?
} catch (ex) {
- complete(Output.create(sysUtil, argv.indexOf('--debug') != -1), ex)
+ complete(Output.create(sysUtil, argv.indexOf('--debug') != -1), callback, ex)
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.