Comparing version 1.7.6 to 1.7.7
@@ -86,8 +86,28 @@ 'use strict'; | ||
this._path = newPath; | ||
if (file.length >= 1) { | ||
// We use 2 as an empty file with a new line would return 1 | ||
if (file.length >= 2) { | ||
var data = JSON.parse(file); | ||
for (var prop in data) { | ||
if ({}.hasOwnProperty.call(data, prop)) { | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = Object.keys(data)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var prop = _step2.value; | ||
this._config[prop] = data[prop]; | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
@@ -94,0 +114,0 @@ } |
{ | ||
"name": "cz", | ||
"version": "1.7.6", | ||
"version": "1.7.7", | ||
"description": "A simple config utility for nodejs", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "xo", | ||
"coverage": "echo '{}' > ./test/config.json && cross-env NODE_ENV=test nyc mocha ./test/**/* --arg:test=arg_test_value && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage && rm -rf ./nyc_output", | ||
"test": "xo && npm run build && npm run coverage", | ||
"gen_test_files": "echo '{}' > ./test/config.json && echo '' > ./test/emptyConfig.json", | ||
"coverage": "npm run gen_test_files && npm run mocha && if-env CI=true && npm run push-coverage || echo ''", | ||
"push-coverage": "cat ./coverage/lcov.info | coveralls && rm -rf ./coverage && rm -rf ./nyc_output", | ||
"mocha": "cross-env NODE_ENV=test nyc mocha ./test/test.js --arg:test=arg_test_value", | ||
"build": "babel -d lib/ src/", | ||
@@ -30,2 +33,3 @@ "prepublish": "npm run build" | ||
"dependencies": { | ||
"if-env": "^1.0.0", | ||
"lodash": "^4.17.4" | ||
@@ -32,0 +36,0 @@ }, |
@@ -14,2 +14,3 @@ 'use strict'; | ||
const configTwo = new Cz(); | ||
const emptyConfig = new Cz(); | ||
@@ -105,2 +106,10 @@ describe('set config using string param and string value', () => { | ||
describe('attempt to load empty config file', () => { | ||
before(() => { | ||
emptyConfig.load(path.join(__dirname, './emptyConfig.json')); | ||
}); | ||
it(`config.get() should return {}`, () => expect(JSON.stringify(emptyConfig.get())).to.equal(JSON.stringify({}))); | ||
}); | ||
describe('new Cz() should create a seperate config store', () => { | ||
@@ -107,0 +116,0 @@ before(() => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
329935
23
680
2
+ Addedif-env@^1.0.0
+ Addedbabel-polyfill@6.26.0(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedif-env@1.0.4(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addednpm-run-all@1.4.0(transitive)
+ Addedps-tree@1.2.0(transitive)
+ Addedregenerator-runtime@0.10.50.11.1(transitive)
+ Addedshell-quote@1.8.1(transitive)
+ Addedwhich@1.3.1(transitive)