diff options
Diffstat (limited to 'deps/npm/node_modules/libnpx/node_modules/dotenv')
5 files changed, 133 insertions, 49 deletions
diff --git a/deps/npm/node_modules/libnpx/node_modules/dotenv/CHANGELOG.md b/deps/npm/node_modules/libnpx/node_modules/dotenv/CHANGELOG.md index 2fcf56b902..1cfa04fa4f 100644 --- a/deps/npm/node_modules/libnpx/node_modules/dotenv/CHANGELOG.md +++ b/deps/npm/node_modules/libnpx/node_modules/dotenv/CHANGELOG.md @@ -4,6 +4,25 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [5.0.0] - 2018-01-29 + +### Added + +- Testing against Node v8 and v9 +- Documentation on trim behavior of values +- Documentation on how to use with `import` + +### Changed + +- *Breaking*: default `path` is now `path.resolve(process.cwd(), '.env')` +- *Breaking*: does not write over keys already in `process.env` if the key has a falsy value +- using `const` and `let` instead of `var` + +### Removed + +- Testing aginst Node v7 + + ## [4.0.0] - 2016-12-23 ### Changed @@ -67,7 +86,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Removed - support for multiple `.env` files. should always use one `.env` file for the current environment -[Unreleased]: https://github.com/motdotla/dotenv/compare/v4.0.0...HEAD +[Unreleased]: https://github.com/motdotla/dotenv/compare/v5.0.0...HEAD +[5.0.0]: https://github.com/motdotla/dotenv/compare/v4.0.0...v5.0.0 [4.0.0]: https://github.com/motdotla/dotenv/compare/v3.0.0...v4.0.0 [3.0.0]: https://github.com/motdotla/dotenv/compare/v2.0.0...v3.0.0 [2.0.0]: https://github.com/motdotla/dotenv/compare/v1.2.0...v2.0.0 diff --git a/deps/npm/node_modules/libnpx/node_modules/dotenv/README.md b/deps/npm/node_modules/libnpx/node_modules/dotenv/README.md index 90836a34b7..4665fd3962 100644 --- a/deps/npm/node_modules/libnpx/node_modules/dotenv/README.md +++ b/deps/npm/node_modules/libnpx/node_modules/dotenv/README.md @@ -5,6 +5,7 @@ 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. [![BuildStatus](https://img.shields.io/travis/motdotla/dotenv/master.svg?style=flat-square)](https://travis-ci.org/motdotla/dotenv) +[![Build status](https://ci.appveyor.com/api/projects/status/rnba2pyi87hgc8xw/branch/master?svg=true)](https://ci.appveyor.com/project/maxbeatty/dotenv/branch/master) [![NPM version](https://img.shields.io/npm/v/dotenv.svg?style=flat-square)](https://www.npmjs.com/package/dotenv) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) [![Coverage Status](https://img.shields.io/coveralls/motdotla/dotenv/master.svg?style=flat-square)](https://coveralls.io/github/motdotla/dotenv?branch=coverall-intergration) @@ -27,7 +28,7 @@ Create a `.env` file in the root directory of your project. Add environment-specific variables on new lines in the form of `NAME=VALUE`. For example: -``` +```dosini DB_HOST=localhost DB_USER=root DB_PASS=s1mpl3 @@ -38,7 +39,7 @@ That's it. `process.env` now has the keys and values you defined in your `.env` file. ```javascript -var db = require('db') +const db = require('db') db.connect({ host: process.env.DB_HOST, username: process.env.DB_USER, @@ -48,8 +49,7 @@ db.connect({ ### Preload -If you are using iojs-v1.6.0 or later, you can use the `--require` (`-r`) command line option to preload dotenv. By doing this, you do not need to require and load dotenv in your application code. - +You can use the `--require` (`-r`) command line option 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`. ```bash $ node -r dotenv/config your_script.js @@ -67,20 +67,31 @@ _Alias: `load`_ `config` will read your .env file, parse the contents, assign it to [`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env), -and return an Object with a _parsed_ key containing the loaded content or an _error_ key if it failed. +and return an Object with a `parsed` key containing the loaded content or an `error` key if it failed. + +```js +const result = dotenv.config() + +if (result.error) { + throw result.error +} + +console.log(result.parsed) +``` + You can additionally, pass options to `config`. ### Options #### Path -Default: `.env` +Default: `path.resolve(process.cwd(), '.env')` You can specify a custom path if your file containing environment variables is named or located differently. ```js -require('dotenv').config({path: '/custom/path/to/your/env/vars'}) +require('dotenv').config({path: '/full/custom/path/to/your/env/vars'}) ``` #### Encoding @@ -101,9 +112,9 @@ variables is available to use. It accepts a String or Buffer and will return an Object with the parsed keys and values. ```js -var dotenv = require('dotenv') -var buf = new Buffer('BASIC=basic') -var config = dotenv.parse(buf) // will return an object +const dotenv = require('dotenv') +const buf = new Buffer('BASIC=basic') +const config = dotenv.parse(buf) // will return an object console.log(typeof config, config) // object { BASIC : 'basic' } ``` @@ -123,6 +134,7 @@ The parsing engine currently supports the following rules: line'} ``` - inner quotes are maintained (think JSON) (`JSON={"foo": "bar"}` becomes `{JSON:"{\"foo\": \"bar\"}"`) +- 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'}`) ## FAQ @@ -175,6 +187,40 @@ For `dotenv@2.x.x`: Use [dotenv-expand](https://github.com/motdotla/dotenv-expan For `dotenv@1.x.x`: We haven't been presented with a compelling use case for expanding variables and believe it leads to env vars that are not "fully orthogonal" as [The Twelve-Factor App](http://12factor.net/config) outlines.<sup>[[1](https://github.com/motdotla/dotenv/issues/39)][[2](https://github.com/motdotla/dotenv/pull/97)]</sup> Please open an issue if you have a compelling use case. +### How do I use dotenv with `import`? + +ES2015 and beyond offers modules that allow you to `export` any top-level `function`, `class`, `var`, `let`, or `const`. + +> 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. +> +> – [ES6 In Depth: Modules](https://hacks.mozilla.org/2015/08/es6-in-depth-modules/) + +You must run `dotenv.config()` before referencing any environment variables. Here's an example of problematic code: + +`errorReporter.js`: + +```js +import { Client } from 'best-error-reporting-service' + +export const client = new Client(process.env.BEST_API_KEY) +``` + +`index.js`: + +```js +import dotenv from 'dotenv' +dotenv.config() + +import errorReporter from './errorReporter' +errorReporter.client.report(new Error('faq example')) +``` + +`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. + +1. Preload dotenv: `node --require dotenv/config index.js` (_Note: you do not need to `import` dotenv with this approach_) +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_) +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) + ## Contributing Guide See [CONTRIBUTING.md](CONTRIBUTING.md) @@ -206,3 +252,6 @@ Here's some projects that expand on dotenv. Check them out. * [require-environment-variables](https://github.com/bjoshuanoah/require-environment-variables) * [dotenv-safe](https://github.com/rolodato/dotenv-safe) * [envalid](https://github.com/af/envalid) +* [lookenv](https://github.com/RodrigoEspinosa/lookenv) +* [run.env](https://www.npmjs.com/package/run.env) +* [dotenv-webpack](https://github.com/mrsteele/dotenv-webpack) diff --git a/deps/npm/node_modules/libnpx/node_modules/dotenv/appveyor.yml b/deps/npm/node_modules/libnpx/node_modules/dotenv/appveyor.yml new file mode 100644 index 0000000000..f55b8a4b6e --- /dev/null +++ b/deps/npm/node_modules/libnpx/node_modules/dotenv/appveyor.yml @@ -0,0 +1,13 @@ +version: "{build}" +build: off +environment: + matrix: + - nodejs_version: "4" + - nodejs_version: "6" + - nodejs_version: "8" + - nodejs_version: "9" +install: + - ps: Install-Product node $env:nodejs_version + - npm install +test_script: + - npm test diff --git a/deps/npm/node_modules/libnpx/node_modules/dotenv/lib/main.js b/deps/npm/node_modules/libnpx/node_modules/dotenv/lib/main.js index eb96e7fd56..1f0df92719 100644 --- a/deps/npm/node_modules/libnpx/node_modules/dotenv/lib/main.js +++ b/deps/npm/node_modules/libnpx/node_modules/dotenv/lib/main.js @@ -1,28 +1,29 @@ 'use strict' -var fs = require('fs') +const fs = require('fs') +const path = require('path') /* * Parses a string or buffer into an object - * @param {String|Buffer} src - source to be parsed - * @returns {Object} + * @param {(string|Buffer)} src - source to be parsed + * @returns {Object} keys and values from src */ function parse (src) { - var obj = {} + const obj = {} // convert Buffers before splitting into lines and processing src.toString().split('\n').forEach(function (line) { // matching "KEY' and 'VAL' in 'KEY=VAL' - var keyValueArr = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/) + const keyValueArr = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/) // matched? if (keyValueArr != null) { - var key = keyValueArr[1] + const key = keyValueArr[1] // default undefined or missing values to empty string - var value = keyValueArr[2] ? keyValueArr[2] : '' + let value = keyValueArr[2] || '' // expand newlines in quoted values - var len = value ? value.length : 0 + const len = value ? value.length : 0 if (len > 0 && value.charAt(0) === '"' && value.charAt(len - 1) === '"') { value = value.replace(/\\n/gm, '\n') } @@ -39,16 +40,18 @@ function parse (src) { /* * Main entry point into dotenv. Allows configuration before loading .env - * @param {Object} options - valid options: path ('.env'), encoding ('utf8') - * @returns {Boolean} + * @param {Object} options - options for parsing .env file + * @param {string} [options.path=.env] - path to .env file + * @param {string} [options.encoding=utf8] - encoding of .env file + * @returns {Object} parsed object or error */ function config (options) { - var path = '.env' - var encoding = 'utf8' + let dotenvPath = path.resolve(process.cwd(), '.env') + let encoding = 'utf8' if (options) { if (options.path) { - path = options.path + dotenvPath = options.path } if (options.encoding) { encoding = options.encoding @@ -57,13 +60,15 @@ function config (options) { try { // specifying an encoding returns a string instead of a buffer - var parsedObj = parse(fs.readFileSync(path, { encoding: encoding })) + const parsed = parse(fs.readFileSync(dotenvPath, { encoding })) - Object.keys(parsedObj).forEach(function (key) { - process.env[key] = process.env[key] || parsedObj[key] + Object.keys(parsed).forEach(function (key) { + if (!process.env.hasOwnProperty(key)) { + process.env[key] = parsed[key] + } }) - return { parsed: parsedObj } + return { parsed } } catch (e) { return { error: e } } diff --git a/deps/npm/node_modules/libnpx/node_modules/dotenv/package.json b/deps/npm/node_modules/libnpx/node_modules/dotenv/package.json index 19c25a8886..f1d99fc5fc 100644 --- a/deps/npm/node_modules/libnpx/node_modules/dotenv/package.json +++ b/deps/npm/node_modules/libnpx/node_modules/dotenv/package.json @@ -1,45 +1,41 @@ { - "_args": [ - [ - "dotenv@4.0.0", - "/Users/zkat/Documents/code/npx" - ] - ], - "_from": "dotenv@4.0.0", - "_id": "dotenv@4.0.0", - "_inBundle": true, - "_integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0=", + "_from": "dotenv@^5.0.1", + "_id": "dotenv@5.0.1", + "_inBundle": false, + "_integrity": "sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow==", "_location": "/libnpx/dotenv", "_phantomChildren": {}, "_requested": { - "type": "version", + "type": "range", "registry": true, - "raw": "dotenv@4.0.0", + "raw": "dotenv@^5.0.1", "name": "dotenv", "escapedName": "dotenv", - "rawSpec": "4.0.0", + "rawSpec": "^5.0.1", "saveSpec": null, - "fetchSpec": "4.0.0" + "fetchSpec": "^5.0.1" }, "_requiredBy": [ "/libnpx" ], - "_resolved": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz", - "_spec": "4.0.0", - "_where": "/Users/zkat/Documents/code/npx", + "_resolved": "https://registry.npmjs.org/dotenv/-/dotenv-5.0.1.tgz", + "_shasum": "a5317459bd3d79ab88cff6e44057a6a3fbb1fcef", + "_spec": "dotenv@^5.0.1", + "_where": "/Users/zkat/Documents/code/npm/node_modules/libnpx", "author": { "name": "scottmotte" }, "bugs": { "url": "https://github.com/motdotla/dotenv/issues" }, + "bundleDependencies": false, "dependencies": {}, + "deprecated": false, "description": "Loads environment variables from .env file", "devDependencies": { "babel": "5.8.23", "coveralls": "^2.11.9", - "lab": "11.1.0", - "semver": "5.3.0", + "lab": "^14.3.2", "should": "11.1.1", "sinon": "1.17.6", "standard": "8.4.0", @@ -66,11 +62,12 @@ "url": "git://github.com/motdotla/dotenv.git" }, "scripts": { + "ci:coverage": "lab test/* -r lcov | coveralls", "lint": "standard", "lint-md": "standard-markdown", "postlint": "npm run lint-md", "pretest": "npm run lint", - "test": "lab test/* -r lcov | coveralls" + "test": "lab" }, - "version": "4.0.0" + "version": "5.0.1" } |