Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cz

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cz - npm Package Compare versions

Comparing version 1.7.7 to 1.7.8

.nyc_output/2d0bc755ae253abf6d230612b1881bf7.json

6

lib/index.js

@@ -118,3 +118,7 @@ 'use strict';

value: function save(newPath) {
_fs2.default.writeFileSync(_path2.default.normalize(newPath || this._path), JSON.stringify(this._config, null, 4) + '\n', 'utf8');
if (arguments.length === 0 && this._path === null) {
throw new Error('No path provided.');
} else {
_fs2.default.writeFileSync(_path2.default.normalize(newPath || this._path), JSON.stringify(this._config, null, 4) + '\n', 'utf8');
}
}

@@ -121,0 +125,0 @@ }, {

4

package.json
{
"name": "cz",
"version": "1.7.7",
"version": "1.7.8",
"description": "A simple config utility for nodejs",

@@ -8,3 +8,3 @@ "main": "lib/index.js",

"test": "xo && npm run build && npm run coverage",
"gen_test_files": "echo '{}' > ./test/config.json && echo '' > ./test/emptyConfig.json",
"gen_test_files": "echo '{}' > ./test/config.json && echo '' > ./test/emptyConfig.json && echo '{}' > ./test/anotherEmptyConfig.json",
"coverage": "npm run gen_test_files && npm run mocha && if-env CI=true && npm run push-coverage || echo ''",

@@ -11,0 +11,0 @@ "push-coverage": "cat ./coverage/lcov.info | coveralls && rm -rf ./coverage && rm -rf ./nyc_output",

@@ -15,2 +15,4 @@ 'use strict';

const emptyConfig = new Cz();
const anotherEmptyConfig = new Cz();
const theLastConfig = new Cz();

@@ -79,3 +81,3 @@ describe('set config using string param and string value', () => {

describe('save config to file', () => {
describe('save config to specified file', () => {
before(() => {

@@ -98,4 +100,33 @@ config.reset();

describe('load config from file', () => {
describe('save config to already loaded file', () => {
before(() => {
const configPath = path.join(__dirname, './anotherEmptyConfig.json');
anotherEmptyConfig.load(configPath);
anotherEmptyConfig.set('test', 'value');
anotherEmptyConfig.save();
});
it(`test should be value`, () => expect(anotherEmptyConfig.get('test')).to.equal('value'));
it(`anotherEmptyConfig.json should contain {"test": "value"}`, () => {
fs.readFile(path.join(__dirname, './anotherEmptyConfig.json'), 'utf8', (err, data) => {
if (err) {
throw err;
}
expect(JSON.parse(data).test).to.equal('value');
});
});
});
describe('save config without providing path', () => {
before(() => {
theLastConfig.set('test', 'value');
});
it(`theLastConfig.save() should throw an error since it has no path`, () => {
expect(() => theLastConfig.save()).to.throw('No path provided.');
});
});
describe('load config from specified file', () => {
before(() => {
config.reset();

@@ -102,0 +133,0 @@ config.load(path.join(__dirname, './config.json'));

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc