2.0.0 • Published 3 years ago

arg-env v2.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

arg-env

Node.js package to work with .env files in the same way as docker and docker-compose via --env-file or "env_file" in package.json

build@ci codecov Maintainability Scrutinizer Code Quality CodeFactor

dependencies Status version license

Installation

npm install --save-dev arg-env

Usage

In addition, check the example of usage

Command-line arguments

node --require=arg-env index.js --env-file=1.env --env-file=2.env

package.json

See npm docs

{
  "config": {
    "env_file": [
      "3.env",
      "./4.env"
    ]
  },
  "scripts": {
    "start:dev": "node --require=arg-env index.js"
  }
}

Parser only

import { parse } from "arg-env"

Features

All specifications are taken from output of actual docker run

Syntax

Closure

Files are independent but rely on global environment

Precedence and overwrite

Files don’t overwrite global environment. Next file takes precedence over previous. In addition, files in package.json has less priority than in command line arguments.

Comparison

Other env JS packages hasn't command-line and package interfaces, more-over, didn't behave like docker: see details ./src/parse.spec.ts. Input is ./src/specs/input.env, output saved in ./src/specs/spec.json via ./src/specs/get.sh.

Tool nameQuotesIsolatedInline commentReuseDefault valueWeird namesError syntaxVar of Var
docker-compose',"YesYesYesYesYesNoNo
arg-env',"YesYesYesYesYesNot yetNot yet
dotenv',"YesNoNoNoNoNoNo
dotenv-expand',"No?NoMoreNoNoNoNo
dotenv-extended',"No?NoNoNoNoNoNo
envfileNo-NoNoNoOtherNoNo

Etc

Experiments with .env stuff

Envs list is taken from docker-compose/docker-compose.yml (service injected) and written to docker/.env