express-load
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -15,3 +15,4 @@ /*! | ||
, path = require('path') | ||
, util = require('util'); | ||
, util = require('util') | ||
, async = require('async'); | ||
@@ -181,4 +182,8 @@ /** | ||
if (!fs.existsSync(entity)) { | ||
this.__log('No such file or directory found at: ' + entity, 'error'); | ||
return false; | ||
if (fs.existsSync(entity + '.js')) { | ||
entity = entity + '.js'; | ||
} else { | ||
this.__log('No such file or directory found at: ' + entity, 'error'); | ||
return false; | ||
} | ||
} | ||
@@ -198,6 +203,5 @@ | ||
for (var s in this.scripts) { | ||
var script = this.scripts[s] | ||
, parts = script.location.split(path.sep) | ||
var self = this; | ||
async.eachSeries(this.scripts, function (script, next) { | ||
var parts = script.location.split(path.sep) | ||
, maps = parts.slice(0) | ||
@@ -208,4 +212,10 @@ , ns = createNamespace(instance, parts) | ||
if (typeof mod === 'function') { | ||
mod = mod.apply(script, arguments); | ||
var notAsync = typeof mod !== 'function' || mod.length < 2; | ||
if (!notAsync) { | ||
mod = mod.call(script, instance, function () { | ||
self.__log('Loaded *.' + map.join('.')); | ||
next(); | ||
}); | ||
} else if (typeof mod === 'function') { | ||
mod = mod.call(script, instance); | ||
} | ||
@@ -223,6 +233,9 @@ | ||
this.__log('Loaded *.' + map.join('.')); | ||
} | ||
return this; | ||
if (notAsync) { | ||
self.__log('Loaded *.' + map.join('.')); | ||
next(); | ||
} | ||
}, function () { | ||
self.__log('All things loaded'); | ||
}); | ||
}; | ||
@@ -257,1 +270,3 @@ | ||
}; | ||
// vim: sw=2 sts=2 ts=2: |
{ | ||
"name": "express-load", | ||
"description": "Autoload modules into an Express application instance, config, models, routes, controllers etc...", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"author": { | ||
@@ -25,2 +25,5 @@ "name": "Jarrad Seers", | ||
], | ||
"dependencies": { | ||
"async": "0.2.9" | ||
}, | ||
"devDependencies": { | ||
@@ -27,0 +30,0 @@ "express": "3.x" |
@@ -91,2 +91,18 @@ | ||
### Async load | ||
If you have an async script to load, _express-load_ will pass a `callback` function to your script and wait this function be called to load remain scripts. | ||
```js | ||
load('syncFoo.js').then('asyncBar.js').then('syncBar.js'); | ||
// asyncBar.js | ||
module.exports = function (app, callback) { | ||
setTimeout(function () { | ||
console.log('After 5 seconds'); | ||
callback(); | ||
}, 5000); | ||
}; | ||
``` | ||
## Logging | ||
@@ -93,0 +109,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
19740
463
206
0
1
1
+ Addedasync@0.2.9
+ Addedasync@0.2.9(transitive)