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
optionsobject supports the following properties:targetsThe 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().grepA single or array ofRegExpobjects which indicatepath inclusions to expose. The regex will be
testedagainst each absolute file path in the
targets. Anabsolute path is considered a match if any of the
grepexpressions match and none of the
ungrepexpressionsmatch.
ungrepA single or array ofRegExpobjects which indicatepath exclusions for expose. The regex will be
testedagainst each absolute file path in the
targets. Anabsolute path is considered a match if any of the
grepexpressions match and none of the
ungrepexpressionsmatch. By default any sub-directory named
node_modulesunder the callers module path will be ignored. If you specify
any
ungrep, your value(s) are used instead.scopeThe namespace scope to expose the exports on. Forexample this can be the callers
exportsobject. If notspecified an empty plain object is used and returned.
recurseAbooleanindicating if expose should recurseany sub-directories. By default this is set to
true.fnA callbackFunctionto invoke for each property importedduring the expose process. The callback is invoked with 3 arguments
as follows
fn(module, propName, propVal)wheremoduleis thestripped (no path or extension) name of the module being imported,
propNameis the name of the property being imported andpropValis the actual value being imported.