adamayres / gulp-extend

A gulp plugin to extend (merge) json contents
https://npmjs.org/package/gulp-extend
MIT License
19 stars 6 forks source link

Maybe should be deprecated for gulp-jsoncombine #7

Open tomyam1 opened 9 years ago

tomyam1 commented 9 years ago

I've be using this plugin for a few months and it worked great for me. After discovering today that it swallows JSON errors I moved to gulp-jsoncombine.

I now think this plugin should be deprecated in favor of gulp-jsoncombine since jsoncombine provides a more general solution and the it takes only 1 line of code to achieve what is done here with jsoncombine. Take the example from the readme:

var jsoncombine = require('gulp-jsoncombine');
var wrap = require('gulp-wrap');
var _ = require('lodash');

gulp.src('./src/*.json')
    .pipe(jsoncombine('text.en.js', function(files) {
       return new Buffer(JSON.stringify(_.merge.apply(_, _.values(files)), null, 2));
    }) //use .js extension since we plan to wrap
    .pipe(wrap('angular.module(\'text\', []).value(<%= contents %>);'))
    .pipe(gulp.dest("./dist"));
Frank3K commented 6 years ago

No lodash needed when using native ES6 like this:

  return new Buffer(JSON.stringify(Object.assign(...Object.values(files)), null, 2));