base-env
Base plugin, creates a normalized environment object from a function, filepath or instance of base.
Install
Install with npm:
$ npm install base-env --save
Usage
var Base = require('base');
var env = require('base-env');
var base = new Base();
base.use(env());
API
Create an env
object with the given name
, function, filepath
or app instance, and options.
Params
name
{String}val
{Object|Function|String}options
{Object}returns
{Object}
Returns true if the given str
matches env.key
, env.name
or env.alias
. When env is created from a filepath, the following properties are also checked:
env.dirname
env.path
env.basename
Params
str
{String}: The string to matchreturns
{Boolean}: Retuns true if a match is made.
Example
var env = app.createEnv('foo', function() {});
env.isMatch('bar');
When env
is created from an existing application instance, the instance is cached on env.app
and env.invoke
is a noop function that simply returns env.app
.
returns
{Object}: Returns the invoked instance.
Example
var foo = new Base();
var bar = new Base();
var env = foo.createEnv('bar', function() {});
env.invoke(bar);
Related projects
You might also be interested in these projects:
- base-generators: Adds project-generator support to your
base
application. | homepage - base-runner: Orchestrate multiple instances of base-methods at once. | homepage
- base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | 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 April 21, 2016.