synapse_fi 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synapse_fi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Mawutor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-02 00:00:00.000000000 Z
11
+ date: 2019-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -100,7 +100,6 @@ executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
- - ".DS_Store"
104
103
  - ".env.sample"
105
104
  - ".gitignore"
106
105
  - Gemfile
@@ -122,18 +121,9 @@ files:
122
121
  - lib/synapse_api/user.rb
123
122
  - lib/synapse_api/users.rb
124
123
  - lib/synapse_api/version.rb
125
- - node_modules/.yarn-integrity
126
- - node_modules/dotenv/CHANGELOG.md
127
- - node_modules/dotenv/LICENSE
128
- - node_modules/dotenv/README.md
129
- - node_modules/dotenv/config.js
130
- - node_modules/dotenv/lib/cli-options.js
131
- - node_modules/dotenv/lib/env-options.js
132
- - node_modules/dotenv/lib/main.js
133
- - node_modules/dotenv/package.json
134
- - package.json
124
+ - lib/synapse_fi.rb
125
+ - pkg/synapse_fi-0.0.3.gem
135
126
  - samples.md
136
- - synapse_fi-0.0.2.gem
137
127
  - synapse_fi.gemspec
138
128
  - yarn.lock
139
129
  homepage: https://rubygems.org/gems/synapse_fi
data/.DS_Store DELETED
Binary file
@@ -1,16 +0,0 @@
1
- {
2
- "systemParams": "darwin-x64-64",
3
- "modulesFolders": [
4
- "node_modules"
5
- ],
6
- "flags": [],
7
- "linkedModules": [],
8
- "topLevelPatterns": [
9
- "dotenv@^6.2.0"
10
- ],
11
- "lockfileEntries": {
12
- "dotenv@^6.2.0": "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064"
13
- },
14
- "files": [],
15
- "artifacts": {}
16
- }
@@ -1,117 +0,0 @@
1
- # Change Log
2
- All notable changes to this project will be documented in this file.
3
- This project adheres to [Semantic Versioning](http://semver.org/).
4
-
5
- ## [Unreleased]
6
-
7
- ## [6.2.0] - 2018-12-03
8
-
9
- ### Added
10
-
11
- - Support preload configuration via environment variables ([#351](https://github.com/motdotla/dotenv/issues/351))
12
-
13
- ## [6.1.0] - 2018-10-08
14
-
15
- ### Added
16
-
17
- - `debug` option for `config` and `parse` methods will turn on logging
18
-
19
- ## [6.0.0] - 2018-06-02
20
-
21
- ### Changed
22
-
23
- - *Breaking:* drop support for Node v4 ([#304](https://github.com/motdotla/dotenv/pull/304))
24
-
25
- ## [5.0.0] - 2018-01-29
26
-
27
- ### Added
28
-
29
- - Testing against Node v8 and v9
30
- - Documentation on trim behavior of values
31
- - Documentation on how to use with `import`
32
-
33
- ### Changed
34
-
35
- - *Breaking*: default `path` is now `path.resolve(process.cwd(), '.env')`
36
- - *Breaking*: does not write over keys already in `process.env` if the key has a falsy value
37
- - using `const` and `let` instead of `var`
38
-
39
- ### Removed
40
-
41
- - Testing against Node v7
42
-
43
-
44
- ## [4.0.0] - 2016-12-23
45
- ### Changed
46
-
47
- - Return Object with parsed content or error instead of false ([#165](https://github.com/motdotla/dotenv/pull/165)).
48
-
49
-
50
- ### Removed
51
-
52
- - `verbose` option removed in favor of returning result.
53
-
54
-
55
- ## [3.0.0] - 2016-12-20
56
- ### Added
57
-
58
- - `verbose` option will log any error messages. Off by default.
59
- - parses email addresses correctly
60
- - allow importing config method directly in ES6
61
-
62
- ### Changed
63
-
64
- - Suppress error messages by default ([#154](https://github.com/motdotla/dotenv/pull/154))
65
- - Ignoring more files for NPM to make package download smaller
66
-
67
- ### Fixed
68
-
69
- - False positive test due to case-sensitive variable ([#124](https://github.com/motdotla/dotenv/pull/124))
70
-
71
- ### Removed
72
-
73
- - `silent` option removed in favor of `verbose`
74
-
75
- ## [2.0.0] - 2016-01-20
76
- ### Added
77
- - CHANGELOG to ["make it easier for users and contributors to see precisely what notable changes have been made between each release"](http://keepachangelog.com/). Linked to from README
78
- - LICENSE to be more explicit about what was defined in `package.json`. Linked to from README
79
- - Testing nodejs v4 on travis-ci
80
- - added examples of how to use dotenv in different ways
81
- - return parsed object on success rather than boolean true
82
-
83
- ### Changed
84
- - README has shorter description not referencing ruby gem since we don't have or want feature parity
85
-
86
- ### Removed
87
- - Variable expansion and escaping so environment variables are encouraged to be fully orthogonal
88
-
89
- ## [1.2.0] - 2015-06-20
90
- ### Added
91
- - Preload hook to require dotenv without including it in your code
92
-
93
- ### Changed
94
- - clarified license to be "BSD-2-Clause" in `package.json`
95
-
96
- ### Fixed
97
- - retain spaces in string vars
98
-
99
- ## [1.1.0] - 2015-03-31
100
- ### Added
101
- - Silent option to silence `console.log` when `.env` missing
102
-
103
- ## [1.0.0] - 2015-03-13
104
- ### Removed
105
- - support for multiple `.env` files. should always use one `.env` file for the current environment
106
-
107
- [Unreleased]: https://github.com/motdotla/dotenv/compare/v6.2.0...HEAD
108
- [6.2.0]: https://github.com/motdotla/dotenv/compare/v6.1.0...v6.2.0
109
- [6.1.0]: https://github.com/motdotla/dotenv/compare/v6.0.0...v6.1.0
110
- [6.0.0]: https://github.com/motdotla/dotenv/compare/v5.0.0...v6.0.0
111
- [5.0.0]: https://github.com/motdotla/dotenv/compare/v4.0.0...v5.0.0
112
- [4.0.0]: https://github.com/motdotla/dotenv/compare/v3.0.0...v4.0.0
113
- [3.0.0]: https://github.com/motdotla/dotenv/compare/v2.0.0...v3.0.0
114
- [2.0.0]: https://github.com/motdotla/dotenv/compare/v1.2.0...v2.0.0
115
- [1.2.0]: https://github.com/motdotla/dotenv/compare/v1.1.0...v1.2.0
116
- [1.1.0]: https://github.com/motdotla/dotenv/compare/v1.0.0...v1.1.0
117
- [1.0.0]: https://github.com/motdotla/dotenv/compare/v0.4.0...v1.0.0
@@ -1,23 +0,0 @@
1
- Copyright (c) 2015, Scott Motte
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright notice,
11
- this list of conditions and the following disclaimer in the documentation
12
- and/or other materials provided with the distribution.
13
-
14
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,295 +0,0 @@
1
- # dotenv
2
-
3
- <img src="https://raw.githubusercontent.com/motdotla/dotenv/master/dotenv.png" alt="dotenv" align="right" />
4
-
5
- Dotenv is a zero-dependency module that loads environment variables from a `.env` file into [`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env). Storing configuration in the environment separate from code is based on [The Twelve-Factor App](http://12factor.net/config) methodology.
6
-
7
- [![BuildStatus](https://img.shields.io/travis/motdotla/dotenv/master.svg?style=flat-square)](https://travis-ci.org/motdotla/dotenv)
8
- [![Build status](https://ci.appveyor.com/api/projects/status/github/motdotla/dotenv?svg=true)](https://ci.appveyor.com/project/motdotla/dotenv/branch/master)
9
- [![NPM version](https://img.shields.io/npm/v/dotenv.svg?style=flat-square)](https://www.npmjs.com/package/dotenv)
10
- [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
11
- [![Coverage Status](https://img.shields.io/coveralls/motdotla/dotenv/master.svg?style=flat-square)](https://coveralls.io/github/motdotla/dotenv?branch=coverall-intergration)
12
-
13
- ## Install
14
-
15
- ```bash
16
- # with npm
17
- npm install dotenv
18
-
19
- # or with Yarn
20
- yarn add dotenv
21
- ```
22
-
23
- ## Usage
24
-
25
- As early as possible in your application, require and configure dotenv.
26
-
27
- ```javascript
28
- require('dotenv').config()
29
- ```
30
-
31
- Create a `.env` file in the root directory of your project. Add
32
- environment-specific variables on new lines in the form of `NAME=VALUE`.
33
- For example:
34
-
35
- ```dosini
36
- DB_HOST=localhost
37
- DB_USER=root
38
- DB_PASS=s1mpl3
39
- ```
40
-
41
- That's it.
42
-
43
- `process.env` now has the keys and values you defined in your `.env` file.
44
-
45
- ```javascript
46
- const db = require('db')
47
- db.connect({
48
- host: process.env.DB_HOST,
49
- username: process.env.DB_USER,
50
- password: process.env.DB_PASS
51
- })
52
- ```
53
-
54
- ### Preload
55
-
56
- You can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#cli_r_require_module) to preload dotenv. By doing this, you do not need to require and load dotenv in your application code. This is the preferred approach when using `import` instead of `require`.
57
-
58
- ```bash
59
- $ node -r dotenv/config your_script.js
60
- ```
61
-
62
- The configuration options below are supported as command line arguments in the format `dotenv_config_<option>=value`
63
-
64
- ```bash
65
- $ node -r dotenv/config your_script.js dotenv_config_path=/custom/path/to/your/env/vars
66
- ```
67
-
68
- Additionally, you can use environment variables to set configuration options. Command line arguments will precede these.
69
-
70
- ```bash
71
- $ DOTENV_CONFIG_<OPTION>=value node -r dotenv/config your_script.js
72
- ```
73
-
74
- ```bash
75
- $ DOTENV_CONFIG_ENCODING=base64 node -r dotenv/config your_script.js dotenv_config_path=/custom/path/to/.env
76
- ```
77
-
78
- ## Config
79
-
80
- _Alias: `load`_
81
-
82
- `config` will read your .env file, parse the contents, assign it to
83
- [`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env),
84
- and return an Object with a `parsed` key containing the loaded content or an `error` key if it failed.
85
-
86
- ```js
87
- const result = dotenv.config()
88
-
89
- if (result.error) {
90
- throw result.error
91
- }
92
-
93
- console.log(result.parsed)
94
- ```
95
-
96
- You can additionally, pass options to `config`.
97
-
98
- ### Options
99
-
100
- #### Path
101
-
102
- Default: `path.resolve(process.cwd(), '.env')`
103
-
104
- You may specify a custom path if your file containing environment variables is located elsewhere.
105
-
106
- ```js
107
- require('dotenv').config({ path: '/full/custom/path/to/your/env/vars' })
108
- ```
109
-
110
- #### Encoding
111
-
112
- Default: `utf8`
113
-
114
- You may specify the encoding of your file containing environment variables.
115
-
116
- ```js
117
- require('dotenv').config({ encoding: 'base64' })
118
- ```
119
-
120
- #### Debug
121
-
122
- Default: `false`
123
-
124
- You may turn on logging to help debug why certain keys or values are not being set as you expect.
125
-
126
- ```js
127
- require('dotenv').config({ debug: process.env.DEBUG })
128
- ```
129
-
130
- ## Parse
131
-
132
- The engine which parses the contents of your file containing environment
133
- variables is available to use. It accepts a String or Buffer and will return
134
- an Object with the parsed keys and values.
135
-
136
- ```js
137
- const dotenv = require('dotenv')
138
- const buf = Buffer.from('BASIC=basic')
139
- const config = dotenv.parse(buf) // will return an object
140
- console.log(typeof config, config) // object { BASIC : 'basic' }
141
- ```
142
-
143
- ### Options
144
-
145
- #### Debug
146
-
147
- Default: `false`
148
-
149
- You may turn on logging to help debug why certain keys or values are not being set as you expect.
150
-
151
- ```js
152
- const dotenv = require('dotenv')
153
- const buf = Buffer.from('hello world')
154
- const opt = { debug: true }
155
- const config = dotenv.parse(buf, opt)
156
- // expect a debug message because the buffer is not in KEY=VAL form
157
- ```
158
-
159
- ### Rules
160
-
161
- The parsing engine currently supports the following rules:
162
-
163
- - `BASIC=basic` becomes `{BASIC: 'basic'}`
164
- - empty lines are skipped
165
- - lines beginning with `#` are treated as comments
166
- - empty values become empty strings (`EMPTY=` becomes `{EMPTY: ''}`)
167
- - single and double quoted values are escaped (`SINGLE_QUOTE='quoted'` becomes `{SINGLE_QUOTE: "quoted"}`)
168
- - new lines are expanded if in double quotes (`MULTILINE="new\nline"` becomes
169
-
170
- ```
171
- {MULTILINE: 'new
172
- line'}
173
- ```
174
-
175
- - inner quotes are maintained (think JSON) (`JSON={"foo": "bar"}` becomes `{JSON:"{\"foo\": \"bar\"}"`)
176
- - whitespace is removed from both ends of the value (see more on [`trim`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)) (`FOO=" some value "` becomes `{FOO: 'some value'}`)
177
-
178
- ## FAQ
179
-
180
- ### Should I commit my `.env` file?
181
-
182
- No. We **strongly** recommend against committing your `.env` file to version
183
- control. It should only include environment-specific values such as database
184
- passwords or API keys. Your production database should have a different
185
- password than your development database.
186
-
187
- ### Should I have multiple `.env` files?
188
-
189
- No. We **strongly** recommend against having a "main" `.env` file and an "environment" `.env` file like `.env.test`. Your config should vary between deploys, and you should not be sharing values between environments.
190
-
191
- > In a twelve-factor app, env vars are granular controls, each fully orthogonal to other env vars. They are never grouped together as “environments”, but instead are independently managed for each deploy. This is a model that scales up smoothly as the app naturally expands into more deploys over its lifetime.
192
- >
193
- > – [The Twelve-Factor App](http://12factor.net/config)
194
-
195
- ### What happens to environment variables that were already set?
196
-
197
- We will never modify any environment variables that have already been set. In particular, if there is a variable in your `.env` file which collides with one that already exists in your environment, then that variable will be skipped. This behavior allows you to override all `.env` configurations with a machine-specific environment, although it is not recommended.
198
-
199
- If you want to override `process.env` you can do something like this:
200
-
201
- ```javascript
202
- const fs = require('fs')
203
- const dotenv = require('dotenv')
204
- const envConfig = dotenv.parse(fs.readFileSync('.env.override'))
205
- for (let k in envConfig) {
206
- process.env[k] = envConfig[k]
207
- }
208
- ```
209
-
210
- ### Can I customize/write plugins for dotenv?
211
-
212
- For `dotenv@2.x.x`: Yes. `dotenv.config()` now returns an object representing
213
- the parsed `.env` file. This gives you everything you need to continue
214
- setting values on `process.env`. For example:
215
-
216
- ```js
217
- const dotenv = require('dotenv')
218
- const variableExpansion = require('dotenv-expand')
219
- const myEnv = dotenv.config()
220
- variableExpansion(myEnv)
221
- ```
222
-
223
- ### What about variable expansion?
224
-
225
- Try [dotenv-expand](https://github.com/motdotla/dotenv-expand)
226
-
227
- ### How do I use dotenv with `import`?
228
-
229
- ES2015 and beyond offers modules that allow you to `export` any top-level `function`, `class`, `var`, `let`, or `const`.
230
-
231
- > When you run a module containing an `import` declaration, the modules it imports are loaded first, then each module body is executed in a depth-first traversal of the dependency graph, avoiding cycles by skipping anything already executed.
232
- >
233
- > – [ES6 In Depth: Modules](https://hacks.mozilla.org/2015/08/es6-in-depth-modules/)
234
-
235
- You must run `dotenv.config()` before referencing any environment variables. Here's an example of problematic code:
236
-
237
- `errorReporter.js`:
238
-
239
- ```js
240
- import { Client } from 'best-error-reporting-service'
241
-
242
- export const client = new Client(process.env.BEST_API_KEY)
243
- ```
244
-
245
- `index.js`:
246
-
247
- ```js
248
- import dotenv from 'dotenv'
249
- import errorReporter from './errorReporter'
250
-
251
- dotenv.config()
252
- errorReporter.client.report(new Error('faq example'))
253
- ```
254
-
255
- `client` will not be configured correctly because it was constructed before `dotenv.config()` was executed. There are (at least) 3 ways to make this work.
256
-
257
- 1. Preload dotenv: `node --require dotenv/config index.js` (_Note: you do not need to `import` dotenv with this approach_)
258
- 2. Import `dotenv/config` instead of `dotenv` (_Note: you do not need to call `dotenv.config()` and must pass options via the command line with this approach_)
259
- 3. Create a separate file that will execute `config` first as outlined in [this comment on #133](https://github.com/motdotla/dotenv/issues/133#issuecomment-255298822)
260
-
261
- ## Contributing Guide
262
-
263
- See [CONTRIBUTING.md](CONTRIBUTING.md)
264
-
265
- ## Change Log
266
-
267
- See [CHANGELOG.md](CHANGELOG.md)
268
-
269
- ## License
270
-
271
- See [LICENSE](LICENSE)
272
-
273
- ## Who's using dotenv
274
-
275
- Here's just a few of many repositories using dotenv:
276
-
277
- * [jaws](https://github.com/jaws-framework/jaws-core-js)
278
- * [node-lambda](https://github.com/motdotla/node-lambda)
279
- * [resume-cli](https://www.npmjs.com/package/resume-cli)
280
- * [phant](https://www.npmjs.com/package/phant)
281
- * [adafruit-io-node](https://github.com/adafruit/adafruit-io-node)
282
- * [mockbin](https://www.npmjs.com/package/mockbin)
283
- * [and many more...](https://www.npmjs.com/browse/depended/dotenv)
284
-
285
- ## Go well with dotenv
286
-
287
- Here's some projects that expand on dotenv. Check them out.
288
-
289
- * [require-environment-variables](https://github.com/bjoshuanoah/require-environment-variables)
290
- * [dotenv-safe](https://github.com/rolodato/dotenv-safe)
291
- * [envalid](https://github.com/af/envalid)
292
- * [lookenv](https://github.com/RodrigoEspinosa/lookenv)
293
- * [run.env](https://www.npmjs.com/package/run.env)
294
- * [dotenv-webpack](https://github.com/mrsteele/dotenv-webpack)
295
- * [env-path](https://github.com/benrei/env-path)
@@ -1,11 +0,0 @@
1
- /* @flow */
2
-
3
- (function () {
4
- require('./lib/main').config(
5
- Object.assign(
6
- {},
7
- require('./lib/env-options'),
8
- require('./lib/cli-options')(process.argv)
9
- )
10
- )
11
- })()
@@ -1,13 +0,0 @@
1
- /* @flow */
2
-
3
- const re = /^dotenv_config_(encoding|path|debug)=(.+)$/
4
-
5
- module.exports = function optionMatcher (args /*: Array<string> */) {
6
- return args.reduce(function (acc, cur) {
7
- const matches = cur.match(re)
8
- if (matches) {
9
- acc[matches[1]] = matches[2]
10
- }
11
- return acc
12
- }, {})
13
- }
@@ -1,18 +0,0 @@
1
- /* @flow */
2
-
3
- // ../config.js accepts options via environment variables
4
- const options = {}
5
-
6
- if (process.env.DOTENV_CONFIG_ENCODING) {
7
- options.encoding = process.env.DOTENV_CONFIG_ENCODING
8
- }
9
-
10
- if (process.env.DOTENV_CONFIG_PATH) {
11
- options.path = process.env.DOTENV_CONFIG_PATH
12
- }
13
-
14
- if (process.env.DOTENV_CONFIG_DEBUG) {
15
- options.debug = process.env.DOTENV_CONFIG_DEBUG
16
- }
17
-
18
- module.exports = options
@@ -1,103 +0,0 @@
1
- /* @flow */
2
- /*::
3
-
4
- type DotenvParseOptions = {
5
- debug?: boolean
6
- }
7
-
8
- // keys and values from src
9
- type DotenvParseOutput = { [string]: string }
10
-
11
- type DotenvConfigOptions = {
12
- path?: string, // path to .env file
13
- encoding?: string, // encoding of .env file
14
- debug?: string // turn on logging for debugging purposes
15
- }
16
-
17
- type DotenvConfigOutput = {
18
- parsed?: DotenvParseOutput,
19
- error?: Error
20
- }
21
-
22
- */
23
-
24
- const fs = require('fs')
25
- const path = require('path')
26
-
27
- function log (message /*: string */) {
28
- console.log(`[dotenv][DEBUG] ${message}`)
29
- }
30
-
31
- // Parses src into an Object
32
- function parse (src /*: string | Buffer */, options /*: ?DotenvParseOptions */) /*: DotenvParseOutput */ {
33
- const debug = Boolean(options && options.debug)
34
- const obj = {}
35
-
36
- // convert Buffers before splitting into lines and processing
37
- src.toString().split('\n').forEach(function (line, idx) {
38
- // matching "KEY' and 'VAL' in 'KEY=VAL'
39
- const keyValueArr = line.match(/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/)
40
- // matched?
41
- if (keyValueArr != null) {
42
- const key = keyValueArr[1]
43
-
44
- // default undefined or missing values to empty string
45
- let value = keyValueArr[2] || ''
46
-
47
- // expand newlines in quoted values
48
- const len = value ? value.length : 0
49
- if (len > 0 && value.charAt(0) === '"' && value.charAt(len - 1) === '"') {
50
- value = value.replace(/\\n/gm, '\n')
51
- }
52
-
53
- // remove any surrounding quotes and extra spaces
54
- value = value.replace(/(^['"]|['"]$)/g, '').trim()
55
-
56
- obj[key] = value
57
- } else if (debug) {
58
- log(`did not match key and value when parsing line ${idx + 1}: ${line}`)
59
- }
60
- })
61
-
62
- return obj
63
- }
64
-
65
- // Populates process.env from .env file
66
- function config (options /*: ?DotenvConfigOptions */) /*: DotenvConfigOutput */ {
67
- let dotenvPath = path.resolve(process.cwd(), '.env')
68
- let encoding /*: string */ = 'utf8'
69
- let debug = false
70
-
71
- if (options) {
72
- if (options.path != null) {
73
- dotenvPath = options.path
74
- }
75
- if (options.encoding != null) {
76
- encoding = options.encoding
77
- }
78
- if (options.debug != null) {
79
- debug = true
80
- }
81
- }
82
-
83
- try {
84
- // specifying an encoding returns a string instead of a buffer
85
- const parsed = parse(fs.readFileSync(dotenvPath, { encoding }), { debug })
86
-
87
- Object.keys(parsed).forEach(function (key) {
88
- if (!process.env.hasOwnProperty(key)) {
89
- process.env[key] = parsed[key]
90
- } else if (debug) {
91
- log(`"${key}" is already defined in \`process.env\` and will not be overwritten`)
92
- }
93
- })
94
-
95
- return { parsed }
96
- } catch (e) {
97
- return { error: e }
98
- }
99
- }
100
-
101
- module.exports.config = config
102
- module.exports.load = config
103
- module.exports.parse = parse
@@ -1,45 +0,0 @@
1
- {
2
- "name": "dotenv",
3
- "version": "6.2.0",
4
- "description": "Loads environment variables from .env file",
5
- "main": "lib/main.js",
6
- "scripts": {
7
- "flow": "flow",
8
- "lint": "standard",
9
- "postlint": "standard-markdown",
10
- "pretest": "npm run lint",
11
- "test": "tap tests/*.js --100"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git://github.com/motdotla/dotenv.git"
16
- },
17
- "keywords": [
18
- "dotenv",
19
- "env",
20
- ".env",
21
- "environment",
22
- "variables",
23
- "config",
24
- "settings"
25
- ],
26
- "readmeFilename": "README.md",
27
- "license": "BSD-2-Clause",
28
- "devDependencies": {
29
- "decache": "^4.5.0",
30
- "flow-bin": "^0.84.0",
31
- "sinon": "^6.3.5",
32
- "standard": "^12.0.1",
33
- "standard-markdown": "^5.0.1",
34
- "tap": "^12.0.1"
35
- },
36
- "dependencies": {},
37
- "engines": {
38
- "node": ">=6"
39
- },
40
- "standard": {
41
- "ignore": [
42
- "flow-typed/"
43
- ]
44
- }
45
- }