{"id":15732287,"url":"https://github.com/stopsopa/dotenv-up","last_synced_at":"2025-03-31T03:25:42.075Z","repository":{"id":57163020,"uuid":"165561974","full_name":"stopsopa/dotenv-up","owner":"stopsopa","description":null,"archived":false,"fork":false,"pushed_at":"2022-11-11T01:15:06.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T06:27:46.845Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/stopsopa.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}},"created_at":"2019-01-13T22:34:05.000Z","updated_at":"2022-11-11T01:10:34.000Z","dependencies_parsed_at":"2022-09-01T00:20:15.661Z","dependency_job_id":null,"html_url":"https://github.com/stopsopa/dotenv-up","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stopsopa%2Fdotenv-up","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stopsopa%2Fdotenv-up/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stopsopa%2Fdotenv-up/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stopsopa%2Fdotenv-up/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stopsopa","download_url":"https://codeload.github.com/stopsopa/dotenv-up/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246409765,"owners_count":20772545,"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":[],"created_at":"2024-10-04T00:08:51.064Z","updated_at":"2025-03-31T03:25:42.050Z","avatar_url":"https://github.com/stopsopa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/dotenv-up.svg)](https://badge.fury.io/js/dotenv-up)\n[![NpmLicense](https://img.shields.io/npm/l/dotenv-up.svg)](https://github.com/stopsopa/dotenv-up/blob/master/LICENSE)\n\n# Installation\n\n```bash\n    yarn add dotenv-up\n```    \n\n# Reference\n\n```javascript\n    require('dotenv-up')(3, true, 'sandbox/server.js');\n    \n    /**\n     * Use like\n     *     require('dotenv-up')(2); // 2 - default assigned to 'deep' parameter\n     *     require('dotenv-up')(2, false); // second param is \"debug\" flag - to show on not show each step on the screen\n     *     require('dotenv-up')(2, false, 'name of load'); // plain text to describe individual use of this library\n     *     require('dotenv-up')({\n                path            = process.cwd(),\n                envfile         = '.env',\n                override        = true, // override values in process.env\n                deep            = 1,\n                startfromlevel  = 0,\n                justreturn      = false, // don't add found values to the process.env global object\n                ... other dotenv options https://www.npmjs.com/package/dotenv\n     *     });\n     *\n     * @param opt\n     * @param debug (def: true)\n     * @param name\n     * @returns {} - object with all extracted variables\n     */\n```\n\n# Docker use\n\n```javascript\n\nrequire('dotenv-up')({\n    override    : false, // don't override existing parameters in process.env by those from .env file\n    deep        : 3,\n}, true, 'sandbox/server.js');\n\n// instead of:\n\nrequire('dotenv-up')(3, true, 'sandbox/server.js');\n// because 'override' flag is by default true\n\n```\n\n# Stacking config in given order from multiple files \n\n```javascript\n\nconst directly = require.main === module;\n\nrequire('dotenv-up')({\n    deep            : 2,\n    startfromlevel  : 1,\n}, !directly, 'index.server');\n\nrequire('dotenv-up')({\n    deep        : 1,\n}, !directly, 'index.server');\n\nif (directly) {\n\n    console.log(JSON.stringify(process.env, null, 4));\n\n    process.exit(0);\n}\n\nmodule.exports = () =\u003e {\n\n    return {\n        origin: \"http://localhost:\" + process.env.NODE_PORT,\n        delayms: 0.2 * 1000,\n    }\n}\n```\n\n# Todo\n\n- [ ] Early detection of spaces around \"=\" https://imgur.com/a/wWml96T \n\n# Tip\n\nIf you need to include other file that use internally again dotenv-up tool in override mode but you don't want those changes of process.env affect proce.env in you'r scope, do:\n\n    const ttt = {...process.env};\n    require('./lib/lib.js') // with its own require('dotenv-up')(1);\n    process.env = ttt;     \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstopsopa%2Fdotenv-up","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstopsopa%2Fdotenv-up","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstopsopa%2Fdotenv-up/lists"}