Base plugin, creates a normalized environment object from a function, filepath or instance of base.
npm install base-env> Base plugin, creates a normalized environment object from a function, filepath or instance of base.
Install with npm:
``sh`
$ npm install --save base-env
`js`
var Base = require('base');
var env = require('base-env');
var base = new Base();
base.use(env());
Create an env object with the given name, function, filepath or app instance, and options. See the Env API docs below.
Params
* name {String}val
* {Object|Function|String}options
* {Object}returns
* {Object}
Example
`js
var base = require('base');
var env = require('base-env');
var app = new Base();
app.use(env());
var env = app.createEnv('foo', function() {});
`
Create an instance of Env with the given name, fn, app instance, and options. The Env class is used by [base-generators][] to handle some of the heavy lifting for resolving generators.
Params
* name {String}fn
* {Function|Object|String}: Function to be lazily invoked, instance, or filepath that resolves to one of the other types when required.app
* {Object}: Base instance to use for invocation context.options
* {Object}
Example
`js`
var env = new Env('foo', function(app) {
// do stuff to app
});
Returns true if the given str matches any of the following properties, in order:
* env.keyenv.name
* env.alias
* env.dirname
* env.path
* env.basename
*
Params
* str {String}: The string to matchreturns
* {Boolean}: Retuns true if a match is made.
Example
`js`
var env = new Env('foo', fucntion(){});
console.log(env.isMatch('bar')) //=> false
console.log(env.isMatch('foo')) //=> true
Invoke env.fn with the given context and options.
Params
* context {Object}: The application instance to use for invoking env.fnopptions
* {Object}returns
* {Object}
Example
`js`
var app = new Base();
env.fn(app, {doStuff: true});
Getter that is set to true when the env being loaded is in the user's working directory.
* returns {Boolean}
Example
`js`
var env = new Env('generator.js', generatorFn, {cwd: process.cwd()});
console.log(env.isDefault);
//=> true
Getter for resolving the namespace of an env. A namespace is created by joining the namespace from a parent instance (if exists) to env.alias (e.g. parent.namespace + '.' + env.alias).
`js
var env = new Env('foo', function() {});
* returns {String}
application. | base application."" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">homepage
- base-runner: Orchestrate multiple instances of base at once. | homepage
- base: Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks | homepage$3
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.$3
| Commits | Contributor |
| --- | --- |
| 37 | jonschlinkert |
| 6 | doowb | $3
$3
_(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)_To generate the readme, run the following command:
`sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
`$3
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
`sh
$ npm install && npm test`
$3
Jon Schlinkert
+ github/jonschlinkert
+ twitter/jonschlinkert
$3
Copyright © 2018, Jon Schlinkert.
Released under the MIT License.
*
_This file was generated by verb-generate-readme, v0.7.0, on July 19, 2018._
[verb]: https://github.com/verbose/verb
[base-generators]: https://github.com/node-base/base-generators
``