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

gulp-json-editor

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-json-editor - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

1

index.js

@@ -35,2 +35,3 @@ /* jshint node: true */

if (file.isNull()) {
this.push(file);
return callback();

@@ -37,0 +38,0 @@ }

2

package.json
{
"name": "gulp-json-editor",
"version": "2.0.0",
"version": "2.0.1",
"description": "A gulp plugin to edit JSON object",

@@ -5,0 +5,0 @@ "license": "MIT",

/* jshint node: true */
/* global describe, it */
/* global it */

@@ -9,131 +9,138 @@ var json = require('../');

describe('gulp-json-editor', function() {
describe('#json()', function() {
it('should modify property of JSON object (by function editor)', function(done) {
it('should modify property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.version = '2.0.0';
return obj;
}));
stream.on('error', done);
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'name': 'test object',
'version': '2.0.0'
});
});
stream.on('end', done);
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.version = '2.0.0';
return obj;
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'name': 'test object',
'version': '2.0.0'
});
done();
});
});
it('should add property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.description = 'this is test';
return obj;
}));
stream.on('error', done);
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'name': 'test object',
'version': '1.0.0',
'description': 'this is test'
});
});
stream.on('end', done);
it('should add property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.description = 'this is test';
return obj;
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'name': 'test object',
'version': '1.0.0',
'description': 'this is test'
});
done();
});
});
it('should remove property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
delete obj.name;
return obj;
}));
stream.on('error', done);
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'version': '1.0.0'
});
obj.should.not.have.property('name');
});
stream.on('end', done);
it('should remove property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
delete obj.name;
return obj;
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'version': '1.0.0'
});
obj.should.not.have.property('name');
done();
});
});
it('should modify nested property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.nested.version = '2.0.1';
return obj;
}));
stream.on('error', done);
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.nested.should.have.properties({
'name': 'nested object',
'version': '2.0.1'
});
});
stream.on('end', done);
it('should modify nested property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.nested.version = '2.0.1';
return obj;
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.nested.should.have.properties({
'name': 'nested object',
'version': '2.0.1'
});
done();
});
});
it('should add nested property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.nested.description = 'this is test for nested';
return obj;
}));
stream.on('error', done);
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.nested.should.have.properties({
'name': 'nested object',
'version': '1.0.0',
'description': 'this is test for nested'
});
});
stream.on('end', done);
it('should add nested property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.nested.description = 'this is test for nested';
return obj;
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.nested.should.have.properties({
'name': 'nested object',
'version': '1.0.0',
'description': 'this is test for nested'
});
done();
});
});
it('should remove nested property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
delete obj.nested.name;
return obj;
}));
stream.on('error', done);
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.nested.should.have.properties({
'version': '1.0.0'
});
obj.nested.should.not.have.property('name');
});
stream.on('end', done);
it('should remove nested property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
delete obj.nested.name;
return obj;
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.nested.should.have.properties({
'version': '1.0.0'
});
obj.nested.should.not.have.property('name');
done();
});
});
it('should multiple properties of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.version = '2.0.0';
obj.description = 'this is test';
delete obj.name;
obj.nested.version = '2.0.1';
obj.nested.description = 'this is test for nested';
delete obj.nested.name;
return obj;
}));
stream.on('error', done);
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'version': '2.0.0',
'description': 'this is test'
});
obj.should.not.have.property('name');
obj.nested.should.have.properties({
'version': '2.0.1',
'description': 'this is test for nested'
});
obj.nested.should.not.have.property('name');
});
stream.on('end', done);
it('should multiple properties of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.version = '2.0.0';
obj.description = 'this is test';
delete obj.name;
obj.nested.version = '2.0.1';
obj.nested.description = 'this is test for nested';
delete obj.nested.name;
return obj;
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'version': '2.0.0',
'description': 'this is test'
});
obj.should.not.have.property('name');
obj.nested.should.have.properties({
'version': '2.0.1',
'description': 'this is test for nested'
});
obj.nested.should.not.have.property('name');
done();
});
});
/* jshint node: true */
/* global describe, it */
/* global it */

@@ -9,99 +9,101 @@ var json = require('../');

describe('gulp-json-editor', function() {
describe('#json()', function() {
it('should modify property of JSON object (by object editor)', function(done) {
it('should modify property of JSON object (by object editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
version: '2.0.0'
}));
var stream = gulp.src('test/test.json').pipe(json({
version: '2.0.0'
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'name': 'test object',
'version': '2.0.0'
});
done();
});
});
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'name': 'test object',
'version': '2.0.0'
});
}).on('end', done);
});
it('should add property of JSON object (by object editor)', function(done) {
it('should add property of JSON object (by object editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
description: 'this is test'
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'name': 'test object',
'version': '1.0.0',
'description': 'this is test'
});
}).on('end', done);
var stream = gulp.src('test/test.json').pipe(json({
description: 'this is test'
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'name': 'test object',
'version': '1.0.0',
'description': 'this is test'
});
done();
});
});
it('should modify nested property of JSON object (by object editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
nested: {
version: '2.0.1'
}
}));
it('should modify nested property of JSON object (by object editor)', function(done) {
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.nested.should.have.properties({
'name': 'nested object',
'version': '2.0.1'
});
}).on('end', done);
var stream = gulp.src('test/test.json').pipe(json({
nested: {
version: '2.0.1'
}
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.nested.should.have.properties({
'name': 'nested object',
'version': '2.0.1'
});
done();
});
});
it('should add nested property of JSON object (by object editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
nested: {
description: 'this is test for nested'
}
}));
it('should add nested property of JSON object (by object editor)', function(done) {
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.nested.should.have.properties({
'name': 'nested object',
'version': '1.0.0',
'description': 'this is test for nested'
});
}).on('end', done);
var stream = gulp.src('test/test.json').pipe(json({
nested: {
description: 'this is test for nested'
}
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.nested.should.have.properties({
'name': 'nested object',
'version': '1.0.0',
'description': 'this is test for nested'
});
done();
});
});
it('should multiple properties of JSON object (by object editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
version: '2.0.0',
description: 'this is test',
nested: {
version: '2.0.1',
description: 'this is test for nested'
}
}));
it('should multiple properties of JSON object (by object editor)', function(done) {
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'version': '2.0.0',
'description': 'this is test',
'name': 'test object'
});
obj.nested.should.have.properties({
'version': '2.0.1',
'description': 'this is test for nested',
'name': 'nested object'
});
}).on('end', done);
var stream = gulp.src('test/test.json').pipe(json({
version: '2.0.0',
description: 'this is test',
nested: {
version: '2.0.1',
description: 'this is test for nested'
}
}));
stream.on('data', function(file) {
var obj = JSON.parse(file.contents);
obj.should.have.properties({
'version': '2.0.0',
'description': 'this is test',
'name': 'test object'
});
obj.nested.should.have.properties({
'version': '2.0.1',
'description': 'this is test for nested',
'name': 'nested object'
});
done();
});
});
/* jshint node: true */
/* global describe, it */
/* global it */
var json = require('../');
var gulp = require("gulp");
require('should');
var jedit = require('../');
var gutil = require('gulp-util');
var fs = require('fs');
var should = require('should');
require('mocha');
describe('gulp-json-editor', function() {
describe('#json()', function() {
it('should raise error when missing option', function(done) {
should(function(){jedit();}).throw('missing "editor function" option');
done();
});
//
// test: raise error when missing option
//
it('should raise error when missing option', function(done) {
(function() {
var stream = gulp.src('test/test.json').pipe(json());
stream.on('error', done);
stream.on('data', done);
}).should.throw('missing "editor function" option');
it('should raise error when invalid type of option', function(done) {
should(function(){jedit(1);}).throw('"editor function" option must be function');
done();
});
it('should do path-through when input is null', function(done) {
jedit({})
.on('data', function(file) {
should(file.contents).eql(null);
done();
});
})
.write(new gutil.File({}));
});
//
// test: raise error when invalid type of option
//
it('should raise error when invalid type of option', function(done) {
(function() {
var stream = gulp.src('test/test.json').pipe(json(100));
stream.on('error', done);
stream.on('data', done);
}).should.throw('"editor function" option must be function');
it('should raise error when streaming input', function(done) {
jedit({})
.on('error', function(err) {
err.message.should.equal('Streaming is not supported');
done();
});
});
})
.write(new gutil.File({
contents: fs.createReadStream('test/test.json')
}));
});
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