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

env-cmd

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-cmd - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

5

CHANGELOG.md
# Changelog
## 5.1.0
- **Feature**: Added new option `--no-override` that when passed will make it so that the env file
vars will not overwrite already defined env vars on `process.env` or in the shell
- **Updated Dev-Dependencies**: `standard >= 10.0.0`, `sinon >= 2.0.0`
## 5.0.0

@@ -4,0 +9,0 @@ - ***BREAKING***: Inline comments are no longer allowed in `.env` files (full line comments are still allowed)

23

lib/index.js

@@ -14,7 +14,12 @@ 'use strict'

// If a .rc file was found then use that
let env = fs.existsSync(rcFileLocation) ? UseRCFile(parsedArgs) : UseCmdLine(parsedArgs)
let parsedEnv = fs.existsSync(rcFileLocation) ? UseRCFile(parsedArgs) : UseCmdLine(parsedArgs)
// Add in the system environment variables to our environment list
env = Object.assign({}, process.env, env)
let env = Object.assign({}, process.env, parsedEnv)
// Override the merge order if --no-override flag set
if (parsedArgs.noOverride) {
env = Object.assign({}, parsedEnv, process.env)
}
// Execute the command with the given environment variables

@@ -38,6 +43,10 @@ const proc = spawn(parsedArgs.command, parsedArgs.commandArgs, {

let command
let noOverride
let commandArgs = args.slice()
while (commandArgs.length) {
const arg = commandArgs.shift()
if (arg === '--no-override') {
noOverride = true
continue
}
// assume the first arg is the env file (or if using .rc the environment name)

@@ -55,3 +64,4 @@ if (!envFile) {

command,
commandArgs
commandArgs,
noOverride
}

@@ -166,3 +176,3 @@ }

return `
Usage: env-cmd [env_file | env_name] command [command options]
Usage: env-cmd [option] [env_file | env_name] command [command options]

@@ -173,2 +183,5 @@ A simple utility for running a cli application using an env config file.

environment configs in one file.
Options:
--no-override - do not override existing process env vars with file env vars
`

@@ -175,0 +188,0 @@ }

{
"name": "env-cmd",
"version": "5.0.0",
"version": "5.1.0",
"description": "Executes a command using the envs in the provided env file",

@@ -32,3 +32,4 @@ "main": "lib/index.js",

"Jon Scheiding <jonscheiding@gmail.com>",
"serapath (Alexander Praetorius) <dev@serapath.de>"
"serapath (Alexander Praetorius) <dev@serapath.de>",
"Anton Versal <ant.ver@gmail.com>"
],

@@ -49,5 +50,5 @@ "license": "MIT",

"proxyquire": "^1.7.10",
"sinon": "^1.17.5",
"standard": "^9.0.0"
"sinon": "^2.0.0",
"standard": "^10.0.0"
}
}

@@ -36,3 +36,2 @@ [![Travis](https://img.shields.io/travis/toddbluhm/env-cmd.svg)](https://travis-ci.org/toddbluhm/env-cmd)

```sh
# uses ./test/.env
./node_modules/.bin/env-cmd ./test/.env node index.js

@@ -83,3 +82,3 @@ ```

For more complex projects, a `.env-cmdrc` file can be defined in the root directory and supports as many environments as you want. Instead of passing the path to a `.env` file to `env-cmd`, simple pass the name of the environment you want use thats in your `.env-cmdrc` file.
For more complex projects, a `.env-cmdrc` file can be defined in the root directory and supports as many environments as you want. Instead of passing the path to a `.env` file to `env-cmd`, simply pass the name of the environment you want to use thats in your `.env-cmdrc` file.

@@ -104,3 +103,10 @@ **.rc file `.env-cmdrc`**

```
### --no-override option
Sometimes you want to set env variables from a file without overriding existing process env vars.
**Terminal**
```sh
ENV1=welcome ./node_modules/.bin/env-cmd --no-override ./test/.env node index.js
```
## Environment File Formats

@@ -133,2 +139,3 @@

- Alexander Praetorius
- Anton Versal

@@ -135,0 +142,0 @@ ## Contributing Guide

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