|
1 |
| - |
2 | 1 | # dotenv-parse-variables
|
3 | 2 |
|
4 |
| -[![Slack Status][slack-image]][slack-url] |
5 |
| -[![NPM version][npm-image]][npm-url] |
6 |
| -[![Build Status][build-image]][build-url] |
7 |
| -[![Code Coverage][codecoverage-image]][codecoverage-url] |
8 |
| -[![Standard JS Style][standard-image]][standard-url] |
9 |
| -[![MIT License][license-image]][license-url] |
| 3 | +[](https://travis-ci.com/niftylettuce/dotenv-parse-variables) |
| 4 | +[](https://codecov.io/gh/niftylettuce/dotenv-parse-variables) |
| 5 | +[](https://github.com/sindresorhus/xo) |
| 6 | +[](https://github.com/prettier/prettier) |
| 7 | +[](https://lass.js.org) |
| 8 | +[](LICENSE) |
10 | 9 |
|
11 |
| -> Parse dotenv files for `Boolean`, `Array`, and `Number` variable types, built for [CrocodileJS][crocodile-url]. |
| 10 | +> Parse dotenv files for `Boolean`, `Array`, and `Number` variable types, built for [Lad][] and [Forward Email][fe]. |
12 | 11 |
|
13 | 12 |
|
14 |
| -## Index |
| 13 | +## Table of Contents |
15 | 14 |
|
16 |
| -* [Example](#example) |
17 | 15 | * [Install](#install)
|
| 16 | +* [Example](#example) |
18 | 17 | * [Usage](#usage)
|
| 18 | +* [Options](#options) |
| 19 | +* [Contributors](#contributors) |
19 | 20 | * [License](#license)
|
20 | 21 |
|
21 | 22 |
|
| 23 | +## Install |
| 24 | + |
| 25 | +[npm][]: |
| 26 | + |
| 27 | +```sh |
| 28 | +npm install dotenv-parse-variables |
| 29 | +``` |
| 30 | + |
| 31 | +[yarn][]: |
| 32 | + |
| 33 | +```sh |
| 34 | +yarn add dotenv-parse-variables |
| 35 | +``` |
| 36 | + |
| 37 | + |
22 | 38 | ## Example
|
23 | 39 |
|
24 | 40 | Imagine you have a configuration file at `.env` with the following:
|
@@ -58,25 +74,19 @@ And you'll see that it outputs the properly parsed variable types:
|
58 | 74 | BOOP: [ 'some', 'thing', 'that', 'goes', 'wow' ],
|
59 | 75 | // NOTE: this was not parsed due to the * asterisk override above
|
60 | 76 | BLEEP: 'false',
|
61 |
| - // NOTE: only the `true*` above was opted out through the use of an asterisk |
| 77 | + // NOTE: only the "true*" above was opted out through the use of an asterisk |
62 | 78 | PING: [ 'ping', 'true', 2, 100 ],
|
63 | 79 | // NOTE: this was not parsed because the string was between bacticks
|
64 | 80 | PONG: 'some,thing,that,goes,wow'
|
65 | 81 | }
|
66 | 82 | ```
|
67 | 83 |
|
68 |
| -If your configuration line ends in `*` it will not be parsed by this package, which allows you to keep values as the `String` variable type if needed. Also when you encapsulate a value between bacticks e.g. \`value\`, the value won't be parsed and it will return as a `String` variable. This can be used in situations where you for example have a ',' inside your string and it should not be parsed as an array. |
69 |
| - |
70 |
| -## Install |
71 |
| - |
72 |
| -```bash |
73 |
| -npm install --save dotenv-parse-variables |
74 |
| -``` |
| 84 | +If your configuration line ends in `*` it will not be parsed by this package, which allows you to keep values as the `String` variable type if needed. Also when you encapsulate a value between bacticks e.g. \`value\`, the value won't be parsed and it will return as a `String` variable. This can be used in situations where you for example have a `,` inside your string and it should not be parsed as an array. |
75 | 85 |
|
76 | 86 |
|
77 | 87 | ## Usage
|
78 | 88 |
|
79 |
| -This package works just fine with [dotenv][dotenv], however we also recommend to use [dotenv-extended][dotenv-extended] and [dotenv-expand][dotenv-expand] as we do in [CrocodileJS][crocodile-url]. |
| 89 | +This package works well with [dotenv][dotenv], however we also recommend to use [dotenv-extended][dotenv-extended] and [dotenv-expand][dotenv-expand] as we do in [Lad][]. You could also simply just use [Lad][] or [@ladjs/env][] specifically. |
80 | 90 |
|
81 | 91 | > Example with `dotenv`:
|
82 | 92 |
|
@@ -112,25 +122,45 @@ console.log(env);
|
112 | 122 | If you don't want to use this package to parse variable types, you could also use [getenv][getenv] (but it requires more work).
|
113 | 123 |
|
114 | 124 |
|
| 125 | +## Options |
| 126 | + |
| 127 | +A second argument can be provided to `dotenvParseVariables` with an object of options. |
| 128 | + |
| 129 | +The defaults are listed below: |
| 130 | + |
| 131 | +* `assignToProcessEnv` (Boolean) - defaults to `true`, whether or not to assign the parsed values to `process.env` |
| 132 | +* `overrideProcessEnv` (Boolean) - defaults to `false`, whether or not to override existing values in `process.env` |
| 133 | +* `ignoreFunctions` (Boolean) - defaults to `true`, whether or not to ignore functions in the parsed values returned |
| 134 | + |
| 135 | + |
| 136 | +## Contributors |
| 137 | + |
| 138 | +| Name | Website | |
| 139 | +| -------------- | ------------------------- | |
| 140 | +| **Nick Baugh** | <http://niftylettuce.com> | |
| 141 | + |
| 142 | + |
115 | 143 | ## License
|
116 | 144 |
|
117 |
| -[MIT][license-url] |
| 145 | +[MIT](LICENSE) © Nick Baugh |
| 146 | + |
118 | 147 |
|
| 148 | +## |
| 149 | + |
| 150 | +[lad]: https://lad.js.org |
| 151 | + |
| 152 | +[fe]: https://forwardemail.net |
| 153 | + |
| 154 | +[npm]: https://www.npmjs.com/ |
| 155 | + |
| 156 | +[yarn]: https://yarnpkg.com/ |
119 | 157 |
|
120 |
| -[license-image]: http://img.shields.io/badge/license-MIT-blue.svg |
121 |
| -[license-url]: LICENSE |
122 |
| -[npm-image]: https://img.shields.io/npm/v/dotenv-parse-variables.svg |
123 |
| -[npm-url]: https://npmjs.org/package/dotenv-parse-variables |
124 |
| -[crocodile-url]: https://crocodilejs.com |
125 |
| -[standard-image]: https://img.shields.io/badge/code%20style-standard%2Bes7-brightgreen.svg |
126 |
| -[standard-url]: https://github.com/crocodilejs/eslint-config-crocodile |
127 |
| -[slack-image]: https://img.shields.io/badge/chat-join%20slack-brightgreen |
128 |
| -[slack-url]: https://join.slack.com/t/ladjs/shared_invite/zt-fqei6z11-Bq2trhwHQxVc5x~ifiZG0g |
129 | 158 | [dotenv]: https://github.com/motdotla/dotenv
|
| 159 | + |
130 | 160 | [dotenv-expand]: https://github.com/motdotla/dotenv-expand
|
| 161 | + |
131 | 162 | [dotenv-extended]: https://github.com/keithmorris/node-dotenv-extended
|
| 163 | + |
132 | 164 | [getenv]: https://github.com/ctavan/node-getenv
|
133 |
| -[build-image]: https://semaphoreci.com/api/v1/niftylettuce/dotenv-parse-variables/branches/master/shields_badge.svg |
134 |
| -[build-url]: https://semaphoreci.com/niftylettuce/dotenv-parse-variables |
135 |
| -[codecoverage-image]: https://codecov.io/gh/niftylettuce/dotenv-parse-variables/branch/master/graph/badge.svg |
136 |
| -[codecoverage-url]: https://codecov.io/gh/niftylettuce/dotenv-parse-variables |
| 165 | + |
| 166 | +[@ladjs/env]: https://github.com/ladjs/env |
0 commit comments