Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

base-env

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-env - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

lib/app.js

73

index.js

@@ -19,30 +19,7 @@ /*!

return function(app) {
if (this.isRegistered('base-env')) return;
return function baseEnv(app) {
if (!isValidInstance(this)) return;
debug('initializing');
if (typeof this.run !== 'function') {
throw new TypeError('expected base-plugins to be registered');
}
/**
* Getter/setter for adding a `namespace` property to `app`. This
* will be removed when `base-namespace` is published
*/
if (typeof this.namespace === 'undefined') {
var namespace = null;
this.define('namespace', {
configurable: true,
set: function(val) {
namespace = val;
},
get: function() {
var name = namespace || this.env && this.env.namespace || this._name;
return this.parent ? (this.parent.namespace + '.' + name) : name;
}
});
}
/**
* Create an `env` object with the given `name`, function, filepath

@@ -58,8 +35,10 @@ * or app instance, and options.

this.define('createEnv', function(name, val, options, parent) {
this.define('createEnv', function(name, val, options) {
debug('createEnv: "%s"', name);
// if the last argument is a function or string, then swap
// `val` and `options`
if (typeof options === 'function' || typeof options === 'string') {
if (name === '' || typeof name !== 'string') {
throw new TypeError('expected name to be a string');
}
if (utils.isAppArg(options)) {
var temp = options;

@@ -72,3 +51,3 @@ options = val;

// we can assume it's an options object
if (utils.typeOf(val) === 'object' && !val.isBase) {
if (utils.isObject(val) && !utils.isAppArg(val)) {
options = val;

@@ -78,3 +57,3 @@ val = name;

var opts = utils.extend({instance: parent || this}, config, options);
var opts = utils.merge({instance: this}, config, options);
if (typeof val === 'undefined') {

@@ -85,20 +64,15 @@ opts.isPath = true;

if (name === '' || typeof name !== 'string') {
throw new TypeError('expected name to be a string');
function env(val) {
return utils.merge({}, opts, val);
}
function env(app, val) {
var aliasFn = opts.toAlias || app.toAlias;
return utils.extend({ aliasFn: aliasFn }, opts, val);
}
switch (utils.typeOf(val)) {
case 'string':
this.env = new EnvPath(name, env(this, { path: val }));
this.env = new EnvPath(name, env({ path: val }), this);
break;
case 'object':
this.env = new EnvApp(name, env(this, { app: val }));
this.env = new EnvApp(name, env({ app: val }), this);
break;
case 'function':
this.env = new EnvFn(name, env(this, { fn: val }));
this.env = new EnvFn(name, env({ fn: val }), this);
break;

@@ -109,5 +83,22 @@ default: {

}
return this.env;
});
return baseEnv;
};
};
function isValidInstance(app) {
var fn = app.options.validatePlugin;
if (typeof fn === 'function' && !fn(app)) {
return false;
}
if (app.isView || app.isList || app.isCollection || app.isItem) {
return false;
}
if (app.isRegistered('base-env')) {
return false;
}
return true;
}
{
"name": "base-env",
"description": "Base plugin, creates a normalized environment object from a function, filepath or instance of base.",
"version": "0.1.0",
"homepage": "https://github.com/jonschlinkert/base-env",
"version": "0.1.1",
"homepage": "https://github.com/node-base/base-env",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/base-env",
"repository": "node-base/base-env",
"bugs": {
"url": "https://github.com/jonschlinkert/base-env/issues"
"url": "https://github.com/node-base/base-env/issues"
},
"license": "MIT",
"files": [
"index.js"
"index.js",
"lib"
],

@@ -23,10 +24,10 @@ "main": "index.js",

"dependencies": {
"base-plugins": "^0.4.5",
"debug": "^2.2.0",
"define-property": "^0.2.5",
"extend-shallow": "^2.0.1",
"global-modules": "^0.2.0",
"is-absolute": "^0.2.3",
"global-modules": "^0.2.1",
"is-absolute": "^0.2.4",
"kind-of": "^3.0.2",
"lazy-cache": "^1.0.3",
"mixin-deep": "^1.1.3",
"resolve": "^1.1.7"

@@ -37,2 +38,3 @@ },

"base-option": "^0.7.0",
"base-plugins": "^0.4.10",
"gulp": "^3.9.1",

@@ -43,7 +45,7 @@ "gulp-eslint": "^2.0.0",

"gulp-mocha": "^2.2.0",
"gulp-unused": "^0.1.2",
"has-glob": "^0.1.1",
"inflection": "^1.8.0",
"mocha": "*",
"mocha": "^2.4.5",
"resolve-up": "^0.5.2",
"templates": "^0.15.9"
"templates": "^0.16.1"
},

@@ -60,2 +62,9 @@ "verb": {

],
"related": {
"list": [
"base",
"base-runner",
"base-generators"
]
},
"reflinks": [

@@ -62,0 +71,0 @@ "verb"

@@ -1,2 +0,2 @@

# base-env [![NPM version](https://img.shields.io/npm/v/base-env.svg)](https://www.npmjs.com/package/base-env) [![Build Status](https://img.shields.io/travis/jonschlinkert/base-env.svg)](https://travis-ci.org/jonschlinkert/base-env)
# base-env [![NPM version](https://img.shields.io/npm/v/base-env.svg?style=flat)](https://www.npmjs.com/package/base-env) [![NPM downloads](https://img.shields.io/npm/dm/base-env.svg?style=flat)](https://npmjs.org/package/base-env) [![Build Status](https://img.shields.io/travis/node-base/base-env.svg?style=flat)](https://travis-ci.org/node-base/base-env)

@@ -49,3 +49,3 @@ > Base plugin, creates a normalized environment object from a function, filepath or instance of base.

### [.env.isMatch](lib/app.js#L53)
### [.env.isMatch](lib/app.js#L59)

@@ -71,3 +71,3 @@ 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.invoke](lib/app.js#L76)
### [.env.invoke](lib/app.js#L82)

@@ -89,2 +89,10 @@ 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`.

## Related projects
You might also be interested in these projects:
* [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://www.npmjs.com/package/base) | [homepage](https://github.com/node-base/base)
* [base-generators](https://www.npmjs.com/package/base-generators): Adds project-generator support to your `base` application. | [homepage](https://github.com/jonschlinkert/base-generators)
* [base-runner](https://www.npmjs.com/package/base-runner): Orchestrate multiple instances of base-methods at once. | [homepage](https://github.com/jonschlinkert/base-runner)
## Contributing

@@ -125,7 +133,7 @@

Copyright © 2016 [Jon Schlinkert](https://github.com/jonschlinkert)
Released under the [MIT license](https://github.com/jonschlinkert/base-env/blob/master/LICENSE).
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/node-base/base-env/blob/master/LICENSE).
***
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on March 13, 2016._
_This file was generated by [verb](https://github.com/verbose/verb), v, on April 02, 2016._
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc