Closed guzart closed 10 years ago
Maybe, it could be useful to use jsoncombine internally before transforming the json files?
Also note that I had to transform the jsoncombine response to remove the filenames :) https://github.com/guzart/gulp-ng-constant/pull/6#issuecomment-58148962
I don't think there's a need to add a dependency to jsoncombine, because internally we already have the contents of the file from the stream, it's just a matter of persisting the object between files and using lodash to extend it.
On the other hand, it makes me wonder what the expected functionality should be when there are multiple files on the stream.
So when you have this code:
gulp
.src([ 'config/global.json', 'config/dev.json' ])
.pipe($.ngConstant({ name: 'config' }))
.pipe(gulp.dest('src/app'));
Do you expect it to behave as a multiplexer and output one file with all the contents merged? or Do you expect it to generate multiple files?
I believe it should be the latter, and that if you want a multiplexer, you should use a plugin like jsoncombine. And then, json combine or alternative, could have an option to extend.
gulp
.src([ 'config/global.json', 'config/dev.json' ])
.pipe(jsoncombine('config.json', { extend: true })
.pipe($.ngConstant({ name: 'config' }))
.pipe(gulp.dest('src/app'));
You are right about the streams and jconsombine usage.
By default, when you have many files in entry, it should generate multiple files. To concat have all contents merged, as you said, jsoncombine or any alternative could be used.
from @intellix comment on #6
so that the following will get the constants from
config/global.json
and extend or override them withconfig/dev.json
: