Expose exports from other modules based on the given options.
The options object supports the following properties:
targets The target path(s) to expose. This can be an array or a single file/dir. If not specified will use the precedence as noted in the jsdocs for defaultTarget().
grep A single or array of RegExp objects which indicate path inclusions to expose. The regex will be tested against each absolute file path in the targets. An absolute path is considered a match if any of the grep expressions match and none of the ungrep expressions match.
ungrep A single or array of RegExp objects which indicate path exclusions for expose. The regex will be tested against each absolute file path in the targets. An absolute path is considered a match if any of the grep expressions match and none of the ungrep expressions match. By default any sub-directory named node_modules under the callers module path will be ignored. If you specify any ungrep, your value(s) are used instead.
scope The namespace scope to expose the exports on. For example this can be the callers exports object. If not specified an empty plain object is used and returned.
recurse A boolean indicating if expose should recurse any sub-directories. By default this is set to true.
fn A callback Function to invoke for each property imported during the expose process. The callback is invoked with 3 arguments as follows fn(module, propName, propVal) where module is the stripped (no path or extension) name of the module being imported, propName is the name of the property being imported and propVal is the actual value being imported.
@param: {Object} options The options object to use for expose.
@returns:
return function(options) {
var opts = defaultOpts(options || {}, parentId),
targets = asArray(opts.targets), len = targets.length;
opts.grep = asArray(opts.grep);
opts.ungrep = asArray(opts.ungrep);
debug("Expose with options:\n", opts);
for (var i = 0; i < len; i++) {
load(targets[i], opts);
}
return opts.scope;
};
};
Expose exports from other modules based on the given
options
.The
options
object supports the following properties:targets
The target path(s) to expose. This can be anarray or a single file/dir. If not specified will
use the precedence as noted in the jsdocs for
defaultTarget()
.grep
A single or array ofRegExp
objects which indicatepath inclusions to expose. The regex will be
test
edagainst each absolute file path in the
targets
. Anabsolute path is considered a match if any of the
grep
expressions match and none of the
ungrep
expressionsmatch.
ungrep
A single or array ofRegExp
objects which indicatepath exclusions for expose. The regex will be
test
edagainst each absolute file path in the
targets
. Anabsolute path is considered a match if any of the
grep
expressions match and none of the
ungrep
expressionsmatch. By default any sub-directory named
node_modules
under the callers module path will be ignored. If you specify
any
ungrep
, your value(s) are used instead.scope
The namespace scope to expose the exports on. Forexample this can be the callers
exports
object. If notspecified an empty plain object is used and returned.
recurse
Aboolean
indicating if expose should recurseany sub-directories. By default this is set to
true
.fn
A callbackFunction
to invoke for each property importedduring the expose process. The callback is invoked with 3 arguments
as follows
fn(module, propName, propVal)
wheremodule
is thestripped (no path or extension) name of the module being imported,
propName
is the name of the property being imported andpropVal
is the actual value being imported.