{"id":13682356,"url":"https://github.com/nsaunders/purescript-dotenv","last_synced_at":"2025-12-12T05:53:43.451Z","repository":{"id":58237346,"uuid":"179357013","full_name":"nsaunders/purescript-dotenv","owner":"nsaunders","description":"Load environment variables from a .env file.","archived":false,"fork":false,"pushed_at":"2023-10-06T14:03:37.000Z","size":183,"stargazers_count":26,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T21:12:50.695Z","etag":null,"topics":["configuration","devops","dotenv","node","purescript"],"latest_commit_sha":null,"homepage":"","language":"PureScript","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/nsaunders.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}},"created_at":"2019-04-03T19:32:04.000Z","updated_at":"2023-08-03T14:06:43.000Z","dependencies_parsed_at":"2023-10-02T00:32:07.291Z","dependency_job_id":null,"html_url":"https://github.com/nsaunders/purescript-dotenv","commit_stats":{"total_commits":168,"total_committers":4,"mean_commits":42.0,"dds":0.125,"last_synced_commit":"8cc285ca6459b0826b28792773bd49131062af5f"},"previous_names":["nicholassaunders/purescript-node-dotenv"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsaunders%2Fpurescript-dotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsaunders%2Fpurescript-dotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsaunders%2Fpurescript-dotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsaunders%2Fpurescript-dotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nsaunders","download_url":"https://codeload.github.com/nsaunders/purescript-dotenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631681,"owners_count":21136562,"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":["configuration","devops","dotenv","node","purescript"],"created_at":"2024-08-02T13:01:44.664Z","updated_at":"2025-12-12T05:53:38.387Z","avatar_url":"https://github.com/nsaunders.png","language":"PureScript","readme":"# purescript-dotenv [![Build](https://github.com/nsaunders/purescript-dotenv/workflows/CI/badge.svg)](https://github.com/nsaunders/purescript-dotenv/actions/workflows/ci.yml) [![Latest release](http://img.shields.io/github/release/nsaunders/purescript-dotenv.svg)](https://github.com/nsaunders/purescript-dotenv/releases) [![PureScript registry](https://img.shields.io/badge/dynamic/json?color=informational\u0026label=registry\u0026query=%24.dotenv.version\u0026url=https%3A%2F%2Fraw.githubusercontent.com%2Fpurescript%2Fpackage-sets%2Fmaster%2Fpackages.json)](https://github.com/purescript/registry) [![purescript-dotenv on Pursuit](https://pursuit.purescript.org/packages/purescript-dotenv/badge)](https://pursuit.purescript.org/packages/purescript-dotenv)\n## Load environment variables from a `.env` file.\n\n\u003cimg src=\"https://github.com/nsaunders/purescript-dotenv/raw/master/meta/img/readme.png\" alt=\"purescript-dotenv\" align=\"right\" /\u003e\n\nAccording to [_The Twelve-Factor App_](https://12factor.net/config), configuration should be strictly separated from code and instead defined in environment variables. If you have found this best practice to be inconvenient in your dev environment, then you may want to give `purescript-dotenv` a try.\n\nBy effectively allowing a configuration file to be consumed through the [`purescript-node-process` environment API](https://pursuit.purescript.org/packages/purescript-node-process/7.0.0/docs/Node.Process#v:getEnv), this library enables your application code to leverage environment variables in production while easing the burden of setting them in development and test environments.\n\nSimply place your `.env` configuration file in the root of your project (ensuring for security reasons not to commit it), and then call `Dotenv.loadFile` at the beginning of your program. Environment variable lookups throughout your program will then fall back to the values defined in `.env`.\n\n### Installation\n\nvia [spago](https://github.com/spacchetti/spago):\n```\nspago install dotenv\n```\n\n### Usage\n\nFirst, place a `.env` file in the root of your project directory. See the [Configuration Format](#configuration-format) section for more information.\n\nNext, import the `Dotenv` module at the entry point of your program (i.e. `Main.purs`):\n\n```purescript\nimport Dotenv (loadFile) as Dotenv\n```\n\nThe `loadFile` function runs in [`Aff`](https://pursuit.purescript.org/packages/purescript-aff/5.1.1/docs/Effect.Aff#t:Aff), so you will also need to import something like [`launchAff_`](https://pursuit.purescript.org/packages/purescript-aff/5.1.1/docs/Effect.Aff#v:launchAff_):\n\n```purescript\nimport Effect.Aff (launchAff_)\n```\n\nFinally, call the `loadFile` function from your `main` function before the rest of your program logic:\n\n```purescript\nmain :: Effect Unit\nmain = launchAff_ do\n  Dotenv.loadFile\n  liftEffect do\n    testVar \u003c- lookupEnv \"TEST_VAR\"\n    logShow testVar\n```\n\n### Configuration Format\n\nThe `.env` file may generally define one environment variable setting per line in the format `VARIABLE_NAME=value`. For example:\n\n```\nEMAIL_FROM=noreply@my.app\nEMAIL_SUBJECT=Testing\nEMAIL_BODY=It worked!\n```\n\n#### Comments\n\nText prefixed with `#` is recognized as a comment and ignored. A comment may appear on its own line or at the end of a line containing a setting. For example:\n\n```\n# Application Settings\n\nGREETING=Hello, Sailor! # A friendly greeting\n```\n\n#### Quoted Values\n\nSetting values may be wrapped with single or double quotes. This is required when the value contains a `#` character so that it is not treated as a comment. It is also necessary when the value includes line breaks. For example:\n\n```\nSUBJECT=\"This one weird trick will double your productivity\"\nMESSAGE=\"Dear friend,\n\nInsert compelling message here.\n\nSincerely,\nBob\"\n```\n\n#### Variable Substitution\n\nThe value of an environment variable (or another setting) can be interpolated into a setting value using the `${VARIABLE_NAME}` syntax. For example:\n\n```\nDB_HOST=127.0.0.1\nDB_NAME=myappdb\nDB_USER=dbuser\nDB_CONN_STR=postgresql://${DB_USER}:${DB_PASS}@${DB_HOST}/${DB_NAME}\n```\n\n#### Command Substitution\n\nThe standard output of a command can also be interpolated into a setting value using the `$(command)` syntax. In the following example, the output of the [`whoami`](http://man7.org/linux/man-pages/man1/whoami.1.html) command is interpolated into the database connection string:\n\n```\nDB_HOST=127.0.0.1\nDB_NAME=myappdb\nDB_CONN_STR=postgresql://$(whoami):${DB_PASS}@${DB_HOST}/${DB_NAME}\n```\n\n#### Additional Parsing Rules\n\nFor a complete specification of parsing rules, please see the [parser tests](test/Parser.purs).\n\n### Examples\n\nTo run the [examples](./examples), clone the repository and run one of the following depending on your package manager and build tool, replacing `\u003cexample-name\u003e` with the name of one of the examples.\n\n[spago](https://github.com/spacchetti/spago):\n```\nspago run -p example/\u003cexample-name\u003e.purs -m Example.\u003cexample-name\u003e\n```\n\n### Other ```dotenv``` implementations\n* Haskell: [stackbuilders/dotenv-hs](https://github.com/stackbuilders/dotenv-hs)\n* Haskell: [pbrisbin/load-env](https://github.com/pbrisbin/load-env)\n* JavaScript: [motdotla/dotenv](http://github.com/motdotla/dotenv)\n* Python: [theskumar/python-dotenv](https://github.com/theskumar/python-dotenv)\n* Ruby: [bkeepers/dotenv](https://github.com/bkeepers/dotenv)\n","funding_links":[],"categories":["PureScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsaunders%2Fpurescript-dotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnsaunders%2Fpurescript-dotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsaunders%2Fpurescript-dotenv/lists"}