在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):rejas/gulp-json-editor开源软件地址(OpenSource Url):https://github.com/rejas/gulp-json-editor开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-json-editorgulp-json-editor is a gulp plugin to edit JSON objects. Usagevar jeditor = require("gulp-json-editor");
/*
edit JSON object by merging with user specific object
*/
gulp.src("./manifest.json")
.pipe(jeditor({
'version': '1.2.3'
}))
.pipe(gulp.dest("./dest"));
/*
edit JSON object by using user specific function
*/
gulp.src("./manifest.json")
.pipe(jeditor(function(json) {
json.version = "1.2.3";
return json; // must return JSON object.
}))
.pipe(gulp.dest("./dest"));
/*
specify [js-beautify](https://github.com/beautify-web/js-beautify) option
*/
gulp.src("./manifest.json")
.pipe(jeditor({
'version': '1.2.3'
},
// the second argument is passed to js-beautify as its option
{
'indent_char': '\t',
'indent_size': 1
}))
.pipe(gulp.dest("./dest"));
/*
specify [deepmerge](https://github.com/TehShrike/deepmerge) option
*/
gulp.src("./manifest.json")
.pipe(jeditor({
"authors": ["tomcat"]
},
// the second argument is passed to js-beautify as its option
{},
// the third argument is passed to deepmerge options, eg, arrayMerge options
{
arrayMerge: function (dist,source,options) {return source;}
}))
.pipe(gulp.dest("./dest")); NoteIn case of such above situation, all of comment and whitespace in source file is NOT kept in destination file. Disable beautificationgulp.src("./manifest.json")
.pipe(jeditor({
'version': '1.2.3'
},
{
beautify: false
}))
.pipe(gulp.dest("./dest")); APIjeditor(editorObject, [jsBeautifyOptions], [deepmergeOptions])editorObjectType: JSON object to merge with. jsBeautifyOptionsType: This object is passed to js-beautify as its option. deepmergeOptionsType: This object is passed to deepmerge as its option. jeditor(editorFunction, [jsBeautifyOptions], [deepmergeOptions])editorFunctionType: The jsBeautifyOptionsType: This object is passed to js-beautify as its option. deepmergeOptionsType: This object is passed to deepmerge as its option. LicenseCopyright (c) 2021 rejas Licensed under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论