added unit testing, and started implementing unit tests...phew

This commit is contained in:
Josh Burman
2019-03-12 22:28:02 -04:00
parent 74aad4a957
commit e8c2539f1b
3489 changed files with 464813 additions and 88 deletions

11
node_modules/env-variable/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,11 @@
language: node_js
node_js:
- "9"
- "8"
- "6"
script:
- "npm run test-travis"
after_script:
- "npm install coveralls && cat coverage/lcov.info | coveralls"
matrix:
fast_finish: true

7
node_modules/env-variable/LICENSE generated vendored Normal file
View File

@ -0,0 +1,7 @@
Copyright 2014 Arnout Kazemier
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

65
node_modules/env-variable/README.md generated vendored Normal file
View File

@ -0,0 +1,65 @@
# env-variable
[![From bigpipe.io][from]](http://bigpipe.io)[![Version npm][version]](http://browsenpm.org/package/env-variable)[![Build Status][build]](https://travis-ci.org/bigpipe/env-variable)[![Dependencies][david]](https://david-dm.org/bigpipe/env-variable)[![Coverage Status][cover]](https://coveralls.io/r/bigpipe/env-variable?branch=master)
[from]: https://img.shields.io/badge/from-bigpipe.io-9d8dff.svg?style=flat-square
[version]: http://img.shields.io/npm/v/env-variable.svg?style=flat-square
[build]: http://img.shields.io/travis/bigpipe/env-variable/master.svg?style=flat-square
[david]: https://img.shields.io/david/bigpipe/env-variable.svg?style=flat-square
[cover]: http://img.shields.io/coveralls/bigpipe/env-variable/master.svg?style=flat-square
A cross platform `env-variable` for browsers and node. Of course, browsers
doesn't have environment variables but we do have hashtags and localStorage
which we will use as fallback.
### hashtags
This is a really easy way of adding some trigger some environment variables that
you might use for debugging. We assume that the hashtag (#) contains
a query string who's key is the name and the value.. the value.
### localStorage
If you want more persisting env variables you can set a query string of env
variables in localStorage. It will attempt to use the `env` variable.
## Installation
This module is written for node and browserify and can be installed using npm:
```
npm install --save env-variable
```
## Usage
This module exposes a node / `module.exports` interface.
```js
var env = require('env-variable')();
```
As you can see from the example above we execute the required module. You can
alternately store it but I don't assume this a common pattern. When you execute
the function it returns an object with all the env variables.
When you execute the function you can alternately pass it an object which will
be seen as the default env variables and all fallbacks and `process.env` will be
merged in to this object.
```js
var env = require('env-variable')({
foo: 'bar',
NODE_ENV: 'production'
});
```
Oh, in `env-variable` we don't really care how you write your env variables. We
automatically add an extra lower case version of the variables so you can access
everything in one consistent way.
And that's basically everything you need to know. *random high fives*.
## License
[MIT](LICENSE)

99
node_modules/env-variable/index.js generated vendored Normal file
View File

@ -0,0 +1,99 @@
'use strict';
var has = Object.prototype.hasOwnProperty;
/**
* Gather environment variables from various locations.
*
* @param {Object} environment The default environment variables.
* @returns {Object} environment.
* @api public
*/
function env(environment) {
environment = environment || {};
if ('object' === typeof process && 'object' === typeof process.env) {
env.merge(environment, process.env);
}
if ('undefined' !== typeof window) {
if ('string' === window.name && window.name.length) {
env.merge(environment, env.parse(window.name));
}
if (window.localStorage) {
try { env.merge(environment, env.parse(window.localStorage.env || window.localStorage.debug)); }
catch (e) {}
}
if (
'object' === typeof window.location
&& 'string' === typeof window.location.hash
&& window.location.hash.length
) {
env.merge(environment, env.parse(window.location.hash.charAt(0) === '#'
? window.location.hash.slice(1)
: window.location.hash
));
}
}
//
// Also add lower case variants to the object for easy access.
//
var key, lower;
for (key in environment) {
lower = key.toLowerCase();
if (!(lower in environment)) {
environment[lower] = environment[key];
}
}
return environment;
}
/**
* A poor man's merge utility.
*
* @param {Object} base Object where the add object is merged in.
* @param {Object} add Object that needs to be added to the base object.
* @returns {Object} base
* @api private
*/
env.merge = function merge(base, add) {
for (var key in add) {
if (has.call(add, key)) {
base[key] = add[key];
}
}
return base;
};
/**
* A poor man's query string parser.
*
* @param {String} query The query string that needs to be parsed.
* @returns {Object} Key value mapped query string.
* @api private
*/
env.parse = function parse(query) {
var parser = /([^=?&]+)=([^&]*)/g
, result = {}
, part;
if (!query) return result;
for (;
part = parser.exec(query);
result[decodeURIComponent(part[1])] = decodeURIComponent(part[2])
);
return result.env || result;
};
//
// Expose the module
//
module.exports = env;

66
node_modules/env-variable/package.json generated vendored Normal file
View File

@ -0,0 +1,66 @@
{
"_from": "env-variable@0.0.x",
"_id": "env-variable@0.0.5",
"_inBundle": false,
"_integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA==",
"_location": "/env-variable",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "env-variable@0.0.x",
"name": "env-variable",
"escapedName": "env-variable",
"rawSpec": "0.0.x",
"saveSpec": null,
"fetchSpec": "0.0.x"
},
"_requiredBy": [
"/enabled"
],
"_resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz",
"_shasum": "913dd830bef11e96a039c038d4130604eba37f88",
"_spec": "env-variable@0.0.x",
"_where": "/Users/josh.burman/Projects/braid/node_modules/enabled",
"author": {
"name": "Arnout Kazemier"
},
"bugs": {
"url": "https://github.com/3rd-Eden/env-variable/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Cross platform environment variables with process.env, window.name, location.hash and localStorage fallbacks",
"devDependencies": {
"assume": "^2.0.1",
"istanbul": "^0.4.5",
"mocha": "^5.1.1"
},
"homepage": "https://github.com/3rd-Eden/env-variable",
"keywords": [
"browser",
"env",
"environment variable",
"environment",
"fallback",
"location.hash",
"process.env",
"variable",
"window.name"
],
"license": "MIT",
"main": "index.js",
"name": "env-variable",
"repository": {
"type": "git",
"url": "git+https://github.com/3rd-Eden/env-variable.git"
},
"scripts": {
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- test.js",
"test": "mocha test.js",
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js",
"watch": "mocha --watch test.js"
},
"version": "0.0.5"
}

46
node_modules/env-variable/test.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
const assume = require('assume');
const env = require('./');
describe('env-variable', function () {
it('merges with process.env as we are running on node', function () {
process.env.TESTING_ENVS = 'wat';
const data = env();
assume(data.TESTING_ENVS).equals('wat');
assume(data.foo).is.a('undefined');
const merged = env({ foo: 'bar' });
assume(merged.TESTING_ENVS).equals('wat');
assume(merged.foo).equals('bar');
});
it('lowercases keys', function () {
process.env.UPPERCASE = 'does NOT touch VALUES';
const data = env({ FOO: 'bar' });
assume(data.UPPERCASE).equals('does NOT touch VALUES');
assume(data.uppercase).equals('does NOT touch VALUES');
assume(data.FOO).equals('bar');
assume(data.foo).equals('bar');
});
describe('#merge', function () {
it('merges objects', function () {
const data = {};
env.merge(data, { foo: 'bar' });
assume(data).deep.equals({ foo: 'bar' });
});
});
describe('#parse', function () {
it('parses basic query strings', function () {
const data = env.parse('foo=bar');
assume(data).is.a('object');
assume(data).deep.equals({ foo: 'bar' });
});
});
});