{"id":15292886,"url":"https://github.com/askirmas/arg-env","last_synced_at":"2026-01-05T15:09:29.931Z","repository":{"id":42622175,"uuid":"405359009","full_name":"askirmas/arg-env","owner":"askirmas","description":"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","archived":false,"fork":false,"pushed_at":"2023-03-06T10:31:11.000Z","size":894,"stargazers_count":0,"open_issues_count":15,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-15T08:15:04.272Z","etag":null,"topics":["arguments","cli","docker","docker-compose","dotenv","env","env-file","environment-variables","loader","node","parser"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/arg-env","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/askirmas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-09-11T11:18:06.000Z","updated_at":"2021-10-18T22:28:18.000Z","dependencies_parsed_at":"2023-02-07T00:02:06.998Z","dependency_job_id":"28d20490-d8b3-4f1e-907b-02f77c1b61dc","html_url":"https://github.com/askirmas/arg-env","commit_stats":{"total_commits":93,"total_committers":1,"mean_commits":93.0,"dds":0.0,"last_synced_commit":"243f9ba169ec7054bf98671a67a2cbd7cfc842b7"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askirmas%2Farg-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askirmas%2Farg-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askirmas%2Farg-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askirmas%2Farg-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/askirmas","download_url":"https://codeload.github.com/askirmas/arg-env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245269007,"owners_count":20587703,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arguments","cli","docker","docker-compose","dotenv","env","env-file","environment-variables","loader","node","parser"],"created_at":"2024-09-30T16:29:44.785Z","updated_at":"2026-01-05T15:09:29.887Z","avatar_url":"https://github.com/askirmas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# arg-env\n\nNode.js package to work with `.env` files in the same way as [docker](https://docs.docker.com/engine/reference/commandline/run/#options) and [docker-compose](https://docs.docker.com/compose/environment-variables/) via argument `--env-file=…` in CLI, `\"env_file\": […]` in package.json and environment variables `ENV_FILE_?=…`\n\n[![build@ci](https://github.com/askirmas/arg-env/workflows/build/badge.svg)](https://github.com/askirmas/arg-env/actions)\n[![codecov](https://codecov.io/gh/askirmas/arg-env/branch/main/graph/badge.svg?token=MGpavfql7g)](https://codecov.io/gh/askirmas/arg-env)\n[![Maintainability](https://api.codeclimate.com/v1/badges/f6a1ef03e39733e2827c/maintainability)](https://codeclimate.com/github/askirmas/arg-env/maintainability)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/askirmas/arg-env/badges/quality-score.png)](https://scrutinizer-ci.com/g/askirmas/arg-env/)\n[![CodeFactor](https://www.codefactor.io/repository/github/askirmas/arg-env/badge)](https://www.codefactor.io/repository/github/askirmas/arg-env)\n\n\u003c!-- [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=askirmas_arg-env\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=askirmas_arg-env) --\u003e\n\u003c!-- [![DeepScan grade](https://deepscan.io](https://deepscan.io/) --\u003e\n\n[![dependencies Status](https://status.david-dm.org/gh/askirmas/arg-env.svg)](https://david-dm.org/askirmas/arg-env)\n[![version](https://img.shields.io/npm/v/arg-env)](https://www.npmjs.com/package/arg-env)\n[![license](https://img.shields.io/npm/l/arg-env)](https://github.com/askirmas/arg-env/blob/master/LICENSE)\n\n## Installation\n\n```bash\nnpm install --save-dev arg-env\n```\n\n## Usage\n\nIn addition, check [the example of usage](https://github.com/askirmas/arg-env/blob/main/__e2e__/script.test.js#L6)\n\n### [Command-line arguments](https://github.com/askirmas/arg-env/blob/main/__e2e__/package.json#L6)\n*See [Node docs](https://nodejs.org/api/cli.html#cli_r_require_module)*\n\n```bash\nnode --require=arg-env index.js --env-file=1.env --env-file=2.env\n\n# jest\nnode -r arg-env node_modules/.bin/jest --env-file=test.env\n```\n\n### [package.json](https://github.com/askirmas/arg-env/blob/main/__e2e__/package.json#L10-L13)\n\n*See [npm docs](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#config)*\n\n```json\n{\n  \"config\": {\n    \"env_file\": [\n      \"3.env\",\n      \"./4.env\"\n    ]\n  },\n  \"scripts\": {\n    \"start:dev\": \"node --require=arg-env index.js\"\n  }\n}\n```\n\n### Parser only\n\n```javascript\nimport { parse } from \"arg-env\"\n```\n\n## Features\n\n\u003cu\u003e*All specifications are taken from output of actual docker run*\u003c/u\u003e\n\n### Syntax\n\n- Comments: [`COMMENTED=comment #ed`](https://github.com/askirmas/arg-env/blob/main/src/specs/input.env#19) is resolved to [`comment`](https://github.com/askirmas/arg-env/blob/main/src/specs/spec.json#5)\n- Quote agnostic: [`V1=val`,`V2='val'`,`V3=\"val\"`](https://github.com/askirmas/arg-env/blob/main/src/specs/input.env#L4-L6) are resolved to [`val`](https://github.com/askirmas/arg-env/blob/main/src/specs/spec.json#L27-30)\n- Reuse: [`EXPR=${VAR1} and ${VAR2}`](https://github.com/askirmas/arg-env/blob/main/src/specs/input.env#L51-L52) is resolved to [`value1 and value2`](https://github.com/askirmas/arg-env/blob/main/src/specs/spec.json#L22-L23)\n- Default value: [`DEFAULT=${UNDEFINED:-val}`](https://github.com/askirmas/arg-env/blob/main/src/specs/input.env#L60) is resolved to [`val`](https://github.com/askirmas/arg-env/blob/main/src/specs/spec.json#L8)\n\n### Closure\n\nFiles are [independent](https://github.com/askirmas/arg-env/blob/main/src/main.test.ts#L82-83) but [rely](https://github.com/askirmas/arg-env/blob/main/src/main.test.ts#L84-L85) on global environment\n\n### Precedence and overwrite\n\nFiles [don’t overwrite](https://github.com/askirmas/arg-env/blob/main/src/main.test.ts#L79) global environment. [Next file takes precedence over previous](https://github.com/askirmas/arg-env/blob/main/src/main.test.ts#L86). In addition, files in package.json has less priority than in command line arguments.\n\n## Comparison\n\nOther env JS packages hasn't command-line and package interfaces, more-over, didn't behave like `docker`: [see details ./src/parse.spec.ts](https://github.com/askirmas/arg-env/blob/main/src/parse.spec.ts). Input is [./src/specs/input.env](https://github.com/askirmas/arg-env/blob/main/src/specs/input.env), output saved in [./src/specs/spec.json](https://github.com/askirmas/arg-env/blob/main/src/specs/spec.json) via `./src/specs/get.sh`.\n\n| Tool name                                                    | [Quotes](https://github.com/askirmas/arg-env/blob/main/src/specs/.docker.env#L2-L9) | [Isolated](https://github.com/askirmas/arg-env/blob/main/src/specs/.docker.env#L54) | [Inline comment](https://github.com/askirmas/arg-env/blob/main/src/specs/.docker.env#L16-L18) | [Reuse](https://github.com/askirmas/arg-env/blob/main/src/specs/.docker.env#L46-L51) | [Default value](https://github.com/askirmas/arg-env/blob/main/src/specs/.docker.env#L57-L60) | [Weird names](https://github.com/askirmas/arg-env/blob/main/src/specs/.docker.env#L22-L36) | [Error syntax](https://github.com/askirmas/arg-env/blob/main/src/specs/.docker.env#L62-L65) | [Var of Var](https://github.com/askirmas/arg-env/blob/main/src/specs/.docker.env#L68-L71) |\n| ------------------------------------------------------------ | ------ | -------- | -------------- | ----- | ------------- | ----------- | ------------ | ---------- |\n| [docker-compose](https://github.com/askirmas/arg-env/blob/main/src/specs/spec.json) | `'`,`\"` | Yes      | Yes            | Yes   | Yes           | Yes         | No           | No         |\n| [arg-env](https://npmjs.com/package/arg-env)                 | `'`,`\"` | Yes      | Yes            | Yes   | Yes           | Yes         | Not yet      | Not yet    |\n| [dotenv](https://npmjs.com/package/dotenv)                   | `'`,`\"` | Yes      | No             | No    | No            | No          | No           | No         |\n| [dotenv-expand](https://npmjs.com/package/dotenv-expand)     | `'`,`\"` | No?      | No             | More  | No            | No          | No           | No         |\n| [dotenv-extended](https://npmjs.com/package/dotenv-extended) | `'`,`\"` | No?      | No             | No    | No            | No          | No           | No         |\n| [envfile](https://npmjs.com/package/envfile)                 | No     | -        | No             | No    | No            | Other       | No           | No         |\n\n## Etc\n\nExperiments with `.env` stuff\n\n- Setup: [`./setup.sh`](./setup.sh)\n- Build: [`./prebuild.sh`](./prebuild.sh)\n   - Launch commands: [`./get_envs.sh`](./get_envs.sh)\n- Result: [output.md](./output.md)\n\nEnvs list is taken from [docker-compose/docker-compose.yml](./docker-compose/docker-compose.yml) (service `injected`) and written to [docker/.env](./docker/.env)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faskirmas%2Farg-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faskirmas%2Farg-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faskirmas%2Farg-env/lists"}