Comparing version 1.2.1 to 1.2.2
@@ -9,2 +9,6 @@ var debug = require('debug')('microboot:run') | ||
if (typeof callback !== 'function') { | ||
throw new Error('Error running phases; invalid callback specified') | ||
} | ||
if (!next) { | ||
@@ -26,5 +30,9 @@ debug('Boot completed.') | ||
return next(function () { | ||
return next(function (err) { | ||
if (err) { | ||
throw err | ||
} | ||
return run(remaining, callback) | ||
}) | ||
} |
{ | ||
"name": "microboot", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Boot up your app in wee little modules with the help of glob.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -69,2 +69,28 @@ # microboot | ||
## Failing to initialise | ||
If something screws up, you _should_ want to stop your app starting. If that's the case, you can throw an error during a step to stop things in their tracks. | ||
For a _synchronous_ step, just go ahead and throw: | ||
``` js | ||
module.exports = function my_broken_api () { | ||
throw new Error('Oh no! It\'s all gone wrong!') | ||
} | ||
``` | ||
For an _asynchronous_ step, return your error as the first argument of the callback: | ||
``` js | ||
module.exports = function my_broken_api (done) { | ||
startUpApi(function (err) { | ||
if (err) { | ||
return done(err) | ||
} | ||
return done() | ||
}) | ||
} | ||
``` | ||
## Examples | ||
@@ -71,0 +97,0 @@ |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
22494
26
377
153
11