Gathering detailed insights and metrics for gulp-merge-json-no-intersection
Gathering detailed insights and metrics for gulp-merge-json-no-intersection
Gathering detailed insights and metrics for gulp-merge-json-no-intersection
Gathering detailed insights and metrics for gulp-merge-json-no-intersection
npm install gulp-merge-json-no-intersection
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A gulp plugin for deep-merging multiple JSON files into one file. Export as JSON or a node module.
1var merge = require('gulp-merge-json'); 2 3/* 4 Basic functionality 5 */ 6gulp.src('jsonFiles/**/*.json') 7 .pipe(merge('combined.json')) 8 .pipe(gulp.dest('./dist')); 9 10/* 11 Edit JSON with function 12 */ 13gulp.src('jsonFiles/**/*.json') 14 .pipe(merge('combined.json', function(parsedJson, file) { 15 if (parsedJson.someValue) { 16 delete parsedJson.otherValue; 17 } 18 19 return parsedJson; 20 })) 21 .pipe(gulp.dest('./dist')); 22 23/* 24 Provide a default object (files are merged in order so object values will be overwritten) 25 */ 26gulp.src('jsonFiles/**/*.json') 27 .pipe(merge('combined.json', false, {someKey: 'defaultValue'})) 28 .pipe(gulp.dest('./dist')); 29 30/* 31 Provide an overwriting object (merged at the end) 32 */ 33gulp.src('jsonFiles/**/*.json') 34 .pipe(merge('combined.json', false, false, {someKey: 'specialValue'})) 35 .pipe(gulp.dest('./dist')); 36 37/* 38 Use module.exports 39 */ 40gulp.src('jsonFiles/**/*.json') 41 .pipe(merge('dataModule.js', false, false, false, true)) 42 .pipe(gulp.dest('./dist')); 43 44/* 45 Use a custom variable to prefix 46 */ 47gulp.src('jsonFiles/**/*.json') 48 .pipe(merge('dataModule.js', false, false, false, 'var my.var')) 49 .pipe(gulp.dest('./dist')); 50 51 52/* 53 Provide options as an object 54*/ 55gulp.src('jsonFiles/**/*.json') 56 .pipe(merge({ 57 fileName: 'dataModule.js', 58 edit: function(parsedJson, file) { 59 if (parsedJson.someValue) { 60 delete parsedJson.otherValue; 61 } 62 }, 63 startObj: {someKey: 'defaultValue'}, 64 endObj: {someKey: 'specialValue'}, 65 exportModule: false, 66 }) 67 .pipe(gulp.dest('./dist')); 68 69/* 70 Provide replacer and space options for JSON.stringify 71*/ 72gulp.src('jsonFiles/**/*.json') 73 .pipe(merge({ 74 fileName: 'dataModule.js', 75 jsonSpace = ' ', 76 jsonReplacer = function() {/*...*/} 77 }) 78 .pipe(gulp.dest('./dist')); 79 80/* 81 Concatenate arrays 82 */ 83gulp.src('jsonFiles/**/*.json') 84 .pipe(merge('combined.json', false, false, false, false, true)) 85 .pipe(gulp.dest('./dist')); 86 87gulp.src('jsonFiles/**/*.json') 88 .pipe(merge({ 89 fileName: 'combined.json', 90 concatArrays: true, 91 })) 92 .pipe(gulp.dest('./dist')); 93 94/* 95 JSON5 96 */ 97gulp.src('jsonFiles/**/*.json5') 98 .pipe(merge({ 99 fileName: 'combined.json5', 100 json5: true, 101 })) 102 .pipe(gulp.dest('./dist'));
1/* 2 json/defaults.json 3 */ 4{ 5 "key1": { 6 "data1": "value1", 7 "data2": "value2" 8 }, 9 "key2": { 10 "dataA": "valueA", 11 "dataB": { 12 "a": "b", 13 "c": "d" 14 } 15 } 16} 17 18/* 19 json/development.json 20 */ 21{ 22 "key1": { 23 "data1": "devValue" 24 }, 25 "key2": { 26 "dataB": { 27 "c": "DEV MODE!" 28 } 29 }, 30 "key3": { 31 "important": "value" 32 } 33}
1/* 2 dist/combined.json 3 */ 4{ 5 "key1": { 6 "data1": "devValue", 7 "data2": "value2" 8 }, 9 "key2": { 10 "dataA": "valueA", 11 "dataB": { 12 "dataA": "valueA", 13 "dataB": { 14 "a": "b", 15 "c": "DEV MODE!" 16 } 17 } 18 }, 19 "key3": { 20 "important": "value" 21 } 22}
No vulnerabilities found.
No security vulnerabilities found.