New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

envlist

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envlist - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

package.json
{
"name": "envlist",
"version": "1.0.0",
"version": "1.1.0",
"description": "envlist is a micro-module (without dependency) for resolving the type of runtime environment between your application convention and another convention (like NODE_ENV).",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -121,2 +121,17 @@ # envlist

### Ensure the current environment
It may be useful to ensure that the current environment is good
and change it if it's not the desired one.
Example, ensure the `dev` environment:
```js
envList.ensure('dev');
```
In this example, if the current environment is not equal to `dev`,
this method change and consolidate the current environment.
Does nothing if the current environment is equal to `dev`.
### Use your own resolver

@@ -195,3 +210,3 @@

`envList` is unit tested with [Unit.js](http://unitjs.com) and [Mocha](https://mochajs.org).
`envlist` is unit tested with [Mocha](https://mochajs.org) and [Unit.js](http://unitjs.com).

@@ -198,0 +213,0 @@ Run the tests

@@ -92,3 +92,3 @@ /**

throw new ReferenceError('Environment not found.');
throw new ReferenceError('Environment "'+ this.env +'" not found.');
}

@@ -100,2 +100,3 @@

* @return {EnvList}
* @throws ReferenceError See EnvList.resolveAppEnv()
*/

@@ -107,6 +108,4 @@ consolidate () {

if(process && process.env) {
process.env.APP_ENV = this.envs[this.env].APP_ENV;
process.env.NODE_ENV = this.envs[this.env].NODE_ENV;
}
process.env.APP_ENV = this.envs[this.env].APP_ENV;
process.env.NODE_ENV = this.envs[this.env].NODE_ENV;

@@ -155,3 +154,3 @@ return this;

throw new ReferenceError('Environment not found.');
throw new ReferenceError('Environment "'+ appEnvName +'" not defined.');
}

@@ -169,4 +168,31 @@

}
/**
* Ensure the current environment.
*
* If the current environment is not equal to `appEnvName`,
* this method change and consolidate the current environment.
*
* Does nothing if the current environment is equal to `appEnvName`.
*
* @param {string} appEnvName (e.g: prod, dev, local, ...).
* @return {EnvList}
* @throws ReferenceError If `appEnvName` is not a valid environment.
*/
ensure(appEnvName) {
if(this.is(appEnvName)) {
return this;
}
if(!this.has(appEnvName)) {
throw new ReferenceError('Environment "'+ appEnvName +'" not defined.');
}
this.env = appEnvName;
this.consolidate();
return this;
}
}
module.exports = EnvList;
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