{"id":8850569,"url":"https://github.com/luqmanoop/sync-dotenv","last_synced_at":"2025-04-05T08:08:31.793Z","repository":{"id":34561826,"uuid":"179499027","full_name":"luqmanoop/sync-dotenv","owner":"luqmanoop","description":"Keep your .env in sync with .env.example","archived":false,"fork":false,"pushed_at":"2023-03-01T01:34:34.000Z","size":459,"stargazers_count":482,"open_issues_count":4,"forks_count":14,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T07:08:16.575Z","etag":null,"topics":["dotenv","env-sync","environment-variables","nodejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/sync-dotenv","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/luqmanoop.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":"2019-04-04T13:05:36.000Z","updated_at":"2025-02-13T09:14:51.000Z","dependencies_parsed_at":"2023-11-28T00:08:57.439Z","dependency_job_id":"189592d1-43be-4ee1-be03-ba65442f18f3","html_url":"https://github.com/luqmanoop/sync-dotenv","commit_stats":{"total_commits":79,"total_committers":10,"mean_commits":7.9,"dds":"0.21518987341772156","last_synced_commit":"7a27534ad91cd66444572072055d7adaeef8666a"},"previous_names":["luqmanoop/sync-dotenv","codeshifu/sync-dotenv"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luqmanoop%2Fsync-dotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luqmanoop%2Fsync-dotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luqmanoop%2Fsync-dotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luqmanoop%2Fsync-dotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luqmanoop","download_url":"https://codeload.github.com/luqmanoop/sync-dotenv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305935,"owners_count":20917208,"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","env-sync","environment-variables","nodejs"],"created_at":"2024-04-30T19:01:05.521Z","updated_at":"2025-04-05T08:08:31.769Z","avatar_url":"https://github.com/luqmanoop.png","language":"TypeScript","funding_links":["https://www.patreon.com/cooproton"],"categories":["TypeScript","nodejs"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"https://i.imgur.com/TRGtM83.gif\"\u003e\n\t\u003ch1 style=\"font-weight:bold;\"\u003esync ⚙️ dotenv\u003c/h1\u003e\n    \u003cp\u003eKeep your .env in sync with .env.example\u003c/p\u003e\n    \u003cimg alt=\"Travis (.org)\" src=\"https://img.shields.io/travis/codeshifu/sync-dotenv.svg?logo=travis\"\u003e\n\t\u003cimg alt=\"Coveralls github\" src=\"https://img.shields.io/coveralls/github/codeshifu/sync-dotenv.svg?style=popout\"\u003e\n\u003c/div\u003e\n\n## Motivation\n\nProjects often rely on environmental variables stored in a `.env` file to run... and because these\nvariables sometimes contain sensitive data, we never add them to source control.\nInstead, these variables are added e.g. to a `.env.example` file so it's easy to\nget the project running for other developers. However, it's very easy to forget to update this file\nwhen a variable is added/updated in `.env` (during development). This can make\nit difficult for devs to get the project running (locally) because they rely on\n`.env.example` file to setup their environment (with their own configs).\n\nEnter `sync-dotenv` 🔥\n\n## Description\n\n`sync-dotenv` automates the process of keeping your\n`.env` in sync with `.env.example`.\n\n## Installation\n\n```bash\n$ npm install -g sync-dotenv\n```\n\nInstall as a dev dependency (**recommended**)\n\n```bash\n$ npm install -D sync-dotenv\n```\n\n## Usage\n\nBy default, `sync-dotenv` looks for a `.env` in your working directory and\nattempt to sync with `.env.example` when no argument is provided. Failure\nto find these files will cause the sync to fail.\n\n```\n$ sync-dotenv\n```\n\nAlternatively, you can use the `--env` and `--sample` flag to specify the source and destination file.\n\n```\n$ sync-dotenv --env foo/.env --sample bar/.env.example\n```\n\nAlso, in the situation where you want to keep multiple files in sync with one source `env` file you can make use of the `--samples` flag specifying a globbing pattern to match:\n\n```sh\n$ sync-dotenv --env foo/.env --samples \"env-samples/*\"\n\n# note: glob pattern should be provided as a string as shown above\n```\n\nFor CLI options, use the `--help` flag\n\n```\n$ sync-dotenv --help\n```\n\nTo run `sync-dotenv` whenever the `.env` file changes, you can for example use [`nodemon`](https://www.npmjs.com/package/nodemon):\n\n```\n$ nodemon --watch .env --exec 'sync-dotenv --env .env --sample .env.example'\n```\n\n## Examples\n\nSync (with `.env.example`) before every commit using [husky](https://github.com/typicode/husky)\n\n```js\n// package.json\n{\n  \"scripts\": {\n    \"env\": \"sync-dotenv\"\n  },\n  \"husky\": {\n    \"hooks\": {\n      \"pre-commit\": \"npm run env\",\n    }\n  }\n}\n```\n\nOr with file other than `.env.example`\n\n```diff\n{\n  \"scripts\": {\n-    \"env\": \"sync-dotenv\"\n+    \"env\": \"sync-dotenv --sample .env.development\"\n  }\n}\n```\n\n### Preserving variables in sample env\n\nSometimes you need to preserve certain variables in your example env file, you can optionally allow this by adding a `sync-dotenv` config in `package.json` like so\n\n```js\n// package.json\n\"scripts\": {\n  ...\n},\n\"sync-dotenv\": {\n  \"preserve\": [\"CHANNEL\"]\n}\n```\n\n### Avoid comments or empty lines in sample env\n\nYou might not want to copy empty lines or comments to your sample env, in this case you can still use `sync-dotenv` config in `package.json` with the following:\n\n```js\n// package.json\n\"scripts\": {\n  ...\n},\n\"sync-dotenv\": {\n  \"emptyLines\": true,\n  \"comments\": false\n}\n```\nNote that you can still combine those options with `preserve`.\n\n## Related\n\n- [parse-dotenv](https://github.com/codeshifu/parse-dotenv) - zero dependency `.env` to javascript object parser\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore --\u003e\n\u003ctable\u003e\u003ctr\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://twitter.com/codeshifu\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/5154605?v=4\" width=\"100px;\" alt=\"Luqman Olushi O.\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eLuqman Olushi O.\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/codeshifu/sync-dotenv/commits?author=codeshifu\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/codeshifu/sync-dotenv/commits?author=codeshifu\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#maintenance-codeshifu\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e \u003ca href=\"#platform-codeshifu\" title=\"Packaging/porting to new platform\"\u003e📦\u003c/a\u003e \u003ca href=\"https://github.com/codeshifu/sync-dotenv/commits?author=codeshifu\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://www.patreon.com/cooproton\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/25608335?v=4\" width=\"100px;\" alt=\"Bolaji Olajide\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eBolaji Olajide\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/codeshifu/sync-dotenv/commits?author=BolajiOlajide\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"http://kizi.to\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/15332525?v=4\" width=\"100px;\" alt=\"Kizito Akhilome\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eKizito Akhilome\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/codeshifu/sync-dotenv/commits?author=akhilome\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/codeshifu/sync-dotenv/commits?author=akhilome\" title=\"Tests\"\u003e⚠️\u003c/a\u003e \u003ca href=\"https://github.com/codeshifu/sync-dotenv/commits?author=akhilome\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## License\n\nThis project is licensed under\n[MIT](https://github.com/codeshifu/sync-dotenv/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluqmanoop%2Fsync-dotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluqmanoop%2Fsync-dotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluqmanoop%2Fsync-dotenv/lists"}