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 1.0.2 to 1.1.0

15

index.js
/* jshint node: true */
var jsbeautify = require('js-beautify').js_beautify;
var through = require('through2');
var PluginError = require('gulp-util').PluginError;
module.exports = function (editor) {
module.exports = function (editor, beautify) {

@@ -29,3 +30,13 @@ // check options

try {
file.contents = new Buffer(JSON.stringify(editor(JSON.parse(file.contents.toString('utf8')))));
var json = JSON.stringify(editor(JSON.parse(file.contents.toString('utf8'))));
if (beautify) {
json = jsbeautify(json, {
'indent_with_tabs': false,
'indent_size': 2,
'indent_char': ' ',
'indent_level': 0,
'brace_style': 'collapse'
});
}
file.contents = new Buffer(json);
}

@@ -32,0 +43,0 @@ catch (err) {

5

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

@@ -28,3 +28,4 @@ "license": "MIT",

"gulp-util": "~2.2.14",
"through2": "~0.4.1"
"through2": "~0.4.1",
"js-beautify": "~1.4.2"
},

@@ -31,0 +32,0 @@ "devDependencies": {

@@ -10,3 +10,3 @@ # gulp-json-editor

gulp.src("./manifest.json")
.pipe(jeditor(function(json) {
.pipe(jeditor(function(json, true) {
// json is normal JSON object. You can modify / add / remove any properties.

@@ -21,10 +21,13 @@ json.version = "1.2.3";

### Note
In case of such situation, all of comment and white space in source file isn't kept in destination file.
In case of such above situation, all of comment in source file isn't kept in destination file.
## API
### jeditor(editorFunction)
### jeditor(editorFunction, [beautify])
#### editorFunction
The `editorFunction` must have the following signature: `function (json) {}`, and must return JSON object.
#### beautify
Pass `true` to beautify before output (default `false`).
## License
[MIT License](http://en.wikipedia.org/wiki/MIT_License)
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