Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

base-register

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-register

Add support for registering a glob of generators to your base app.

Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

base-register NPM version NPM downloads Build Status

Add support for registering a glob of generators to your base app.

Install

Install with npm:

$ npm install base-register --save

Usage

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-c

Before

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:

  • filepath The fully resolved, absolute path to the generator
  • basename The basename of the absolute directory path. So the basename of foo/bar/baz/index.js would be baz

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`

You might also be interested in these projects:

  • base-generators: Adds project-generator support to your base application. | 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 docs

Or, if verb is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

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.

Keywords

base

FAQs

Package last updated on 05 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts