{"id":20252441,"url":"https://github.com/ivandotv/puntoenv","last_synced_at":"2025-04-10T23:16:55.733Z","repository":{"id":65939689,"uuid":"597167865","full_name":"ivandotv/puntoenv","owner":"ivandotv","description":"PuntoEnv enables you to load  .env files in to process.env  and also do variable expansion in a predetermined order based on the NODE_ENV environment variable value","archived":false,"fork":false,"pushed_at":"2025-03-24T04:45:10.000Z","size":701,"stargazers_count":4,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T23:16:48.040Z","etag":null,"topics":["dotenv","dotenv-co","dotenv-expand","dotenv-loader","dotenv-parser","environment-variables"],"latest_commit_sha":null,"homepage":"","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/ivandotv.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-03T19:23:30.000Z","updated_at":"2025-03-24T04:44:44.000Z","dependencies_parsed_at":"2023-07-18T02:01:28.870Z","dependency_job_id":"50bbc1cc-0b33-4a1b-a461-72be827d4aeb","html_url":"https://github.com/ivandotv/puntoenv","commit_stats":{"total_commits":24,"total_committers":3,"mean_commits":8.0,"dds":"0.33333333333333337","last_synced_commit":"fd93b71f92c1c34adfbcf31f5e75a515a94395d3"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":"ivandotv/microbundle-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fpuntoenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fpuntoenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fpuntoenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fpuntoenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivandotv","download_url":"https://codeload.github.com/ivandotv/puntoenv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312132,"owners_count":21082638,"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":["dotenv","dotenv-co","dotenv-expand","dotenv-loader","dotenv-parser","environment-variables"],"created_at":"2024-11-14T10:16:45.614Z","updated_at":"2025-04-10T23:16:55.715Z","avatar_url":"https://github.com/ivandotv.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PuntoEnv\n\n[![Test](https://github.com/ivandotv/puntoenv/actions/workflows/CI.yml/badge.svg)](https://github.com/ivandotv/puntoenv/actions/workflows/CI.yml)\n[![GitHub license](https://img.shields.io/github/license/ivandotv/puntoenv)](https://github.com/ivandotv/puntoenv/blob/main/LICENSE)\n\nPuntoEnv is a simple package that enables you to load `.env` files in to `process.env` and also do variable expansion in a predetermined order based on the `NODE_ENV` environment variable value.\n\n\u003c!-- toc --\u003e\n\n- [Motivation](#motivation)\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n  * [Custom ENV variable](#custom-env-variable)\n  * [Loaded file callback](#loaded-file-callback)\n- [How it works.](#how-it-works)\n  * [Variable expansion](#variable-expansion)\n- [License](#license)\n\n\u003c!-- tocstop --\u003e\n\n## Motivation\n\nI like how [Next.js loads `.env` files](https://nextjs.org/docs/basic-features/environment-variables#environment-variable-load-order) so I decided to make a similar utility module so I could use it everywhere else. Under the hood, it uses [`dotenv`](https://www.npmjs.com/package/dotenv) and [`dotenv-expand`](https://www.npmjs.com/package/dotenv-expand) packages.\n\n## Installation\n\n```sh\nnpm i puntoenv\n```\n\n## Getting Started\n\nSetup is really simple, just pass in a path to the directory that has your `.env` files and that's it!\n\n```ts\nimport { setupEnv } from 'puntoenv'\n\nsetupEnv('/path/to/your-dir/')\n```\n### Custom ENV variable\n\nAlso note that `NODE_ENV` will be the default environment variable that will be checked, but you can use any other variable.\n```ts\n//use NODE_CONTEXT to determine which files to load\nsetupEnv('/path/to/your-dir/','NODE_CONTEXT')\n```\n\nMake sure you call the function as early as possible in your code.\n\n### Loaded file callback\n\nYou can pass in optional `onLoad` callback (to the options object), that will fire for every loaded file. Inside the callback there is info about the `path`, `filename` and the result of the\n`dotEnv.config` method call.\n\n```ts\nsetupEnv(__dirname, {\n  onLoad: (data) =\u003e {\n    console.log('path ',data.path)\n    console.log('filename ',data.filename)\n    console.log('result ',data.result) // {error?: Error , parsed:Record\u003cstring,string\u003e}\n  },\n})\n\n```\n## How it works.\n\nPuntoEnv will load `.env` files in a particular order.\nEnvironment variables are looked up in the following places, in order, stopping once the variable is found.\nEnvironment variables that already exist have the highest priority and will not be overwritten by .env files.\n\n```sh\nconst value = process.env.NODE_ENV // production\n\n- process.env\n- .env.$(value).local // .env.production.local\n- .env.local\n- .env.$(value) // .env.production\n- .env\n```\n\n\nOne exception to this rule is when the `NODE_ENV=test` in that case `*.local` files will not be loaded as you expect tests to produce the same results for everyone (but you can use `.env.test` file).\n\nI would also recommend adding all `.env*.local` files to the `.gitignore` file.\n\n### Variable expansion\n\nAfter all the files have been processed, the variable expansion will take place.\nBefore expansion:\n\n```sh\nSERVER=www.example.com:$PORT\nPORT=3000\n```\n\nAfter expansion:\n\n```sh\nSERVER=www.example.com:3000\nPORT=3000\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivandotv%2Fpuntoenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivandotv%2Fpuntoenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivandotv%2Fpuntoenv/lists"}