Package Exports
- base-register
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (base-register) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
base-register

Add support for registering a glob of generators to your base app.
Install
Install with npm:
$ npm install base-register --saveUsage
var generators = require('base-generators');
var register = require('base-register');
var Base = require('base');
var base = new Base();
base.use(generators());
base.use(register());API
Params
patterns{Array|String}: End glob patterns with a slash to register a generator in a directory.options{Object}returns{Object}: Returns the instance for chaining
Example
app.register('generators/*');Example
Let's say you have a generator with three sub-generators in directories:
my-generator
L generators/sub-generator-a
L generators/sub-generator-b
L generators/sub-generator-cBefore
Typically, with base-generators you would register the sub-generators in your generator like this:
module.exports = function(app) {
app.register('a', require('./generators/sub-generator-a'));
app.register('b', require('./generators/sub-generator-b'));
app.register('c', require('./generators/sub-generator-c'));
};After
With this plugin, you can do this:
module.exports = function(app) {
app.register('generators/*/');
};Options
Pass options as the second argument. Anything that is supported by [matched][] may be used.
Example
module.exports = function(app) {
app.register('*/', {matchBase: '*.js', cwd: 'generators'});
};Rename function
Pass a custom rename function as the last argument.
Params
The function exposes the following parameters:
filepathThe fully resolved, absolute path to the generatorbasenameThe basename of the absolute directory path. So the basename offoo/bar/baz/index.jswould bebaz
Example
Given the same generators from the first examples:
app.register('generators/*/index.js', function(name, filepath) {
return 'foo-' + name;
});
// registers `foo-a`, `foo-b`, and `foo-c`Related projects
You might also be interested in these projects:
- base-generators: Adds project-generator support to your
baseapplication. | homepage - base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
- generate: Fast, composable, highly extendable project generator with a user-friendly and expressive API. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
Generate readme and API documentation with verb:
$ npm install verb && npm run docsOr, if verb is installed globally:
$ verbRunning tests
Install dev dependencies:
$ npm install -d && npm testAuthor
Jon Schlinkert
License
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on May 05, 2016.