Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

with-env

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

with-env - npm Package Compare versions

Comparing version
0.1.1
to
1.3.37
+1
-23
package.json

@@ -1,23 +0,1 @@

{
"name": "with-env",
"version": "0.1.1",
"description": "Read and apply .env file if exists in the working directory",
"main": "index.js",
"scripts": {
"test": "prova"
},
"devDependencies": {
"prova": "*"
},
"keywords": [
"env",
"environment",
"foreman"
],
"repository": {
"url": "git@github.com:azer/with-env.git",
"type": "git"
},
"author": "azer",
"license": "BSD"
}
{"name":"with-env","version":"1.3.37"}
PORT=8080
AWS_KEY=abcde
DB=user@foobar.com/corge
DBSET=mongodb://user:pass@foobar.com:4000,barfoo.com:5000/corge?replicaSet=rs-ds012345
DQUOTE="this is quoted"
SQUOTE='this is also quoted'

Sorry, the diff of this file is not supported yet

var read = require("fs").readFileSync;
module.exports = apply;
function apply () {
var doc;
try {
doc = read('./.env').toString().split('\n');
} catch (exc) {
return;
}
var i = -1;
var len = doc.length;
var row;
while (++i < len) {
if (!doc[i]) continue;
row = doc[i].split(/\s*=\s*/);
process.env[row.shift()] = row.join('=').replace(/['"]/g,'');
}
}
## with-env
Read and apply .env file (if exists) in the working directory.
## Install
```bash
$ npm install with-env
```
## Usage
Create an `.env` file:
```
PORT=8080
AWS_KEY=abcde
DB=user@foobar.com/corge
```
And call `with-env` on top of your module:
```js
require('with-env')()
console.log(process.env.AWS_KEY)
// => 'abcde'
```