Git Product home page Git Product logo

askirmas / arg-env Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 894 KB

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

Home Page: https://www.npmjs.com/package/arg-env

License: MIT License

Shell 12.14% Dockerfile 0.23% TypeScript 77.95% JavaScript 9.68%
dotenv env environment-variables node docker docker-compose cli env-file loader parser arguments

arg-env's Introduction

arg-env

Node.js package to work with .env files in the same way as docker and docker-compose via argument --env-file=… in CLI, "env_file": […] in package.json and environment variables ENV_FILE_?=…

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

See Node docs

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

# jest
node -r arg-env node_modules/.bin/jest --env-file=test.env

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 name Quotes Isolated Inline comment Reuse Default value Weird names Error syntax Var of Var
docker-compose '," Yes Yes Yes Yes Yes No No
arg-env '," Yes Yes Yes Yes Yes Not yet Not yet
dotenv '," Yes No No No No No No
dotenv-expand '," No? No More No No No No
dotenv-extended '," No? No No No No No No
envfile No - No No No Other No No

Etc

Experiments with .env stuff

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

arg-env's People

Watchers

 avatar  avatar  avatar

arg-env's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.