-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
index.js
49 lines (39 loc) · 1.06 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var wrap = require('./lib/wrap');
var fs = require('fs');
var path = require('path');
var exports = module.exports = function (opts) {
if (Array.isArray(opts)) {
opts = { require : opts };
}
else if (typeof opts !== 'object') {
opts = { require : [ opts ] };
}
if (!opts.require) opts.require = [];
if (opts.base) {
throw new Error('base is no longer a valid parameter');
}
var w = wrap(opts.require, opts.ignore);
if (opts.entry) {
if (Array.isArray(opts.entry)) {
opts.entry.forEach(function (e) {
w.addEntry(e);
});
}
else {
w.addEntry(opts.entry);
}
}
var self = function (req, res, next) {
// ...
};
Object.keys(w).forEach(function (key) {
self[key] = w[key];
});
Object.keys(wrap.prototype).forEach(function (key) {
self[key] = w[key].bind(w);
});
return self;
};
exports.bundle = function (opts) {
return exports(opts).bundle();
};