gulp-json-concat

⚡️ Combine several JSON files into one with Gulp

MIT License

Downloads
7.6K
Stars
11
Committers
4

gulp-json-concat

Combine several JSON files with Gulp

gulp-json-concat is a fork of gulp-jsoncombine with new few options.

Install

$ npm install --save-dev gulp-json-concat

Usage

You can combine json files that are in subfolders. The json generated will remove the name of these folders to keep only the name of the file.

var gulp = require('gulp');
var jsonConcat = require('gulp-json-concat');

gulp.task('json', function () {
  return gulp.src('db/**/*.json')
    .pipe(jsonConcat('db.json',function(data){
      return new Buffer(JSON.stringify(data));
    }))
    .pipe(gulp.dest('dist/json'));
});

API

jsonConcat(fileName, processor)

fileName

Type: String

The output filename.

processor

Type: Function

The function that will be called with the dictionary containing all the data from the processes JSON files, where the keys of the dictionary, would be the names of the files (sans the '.json' postfix).

The function should return a new Buffer that would be writter to the output file.

Changelog

0.2.0 Update

  • Update dependencies

0.1.1 Update and corrections

  • Update dependencies
  • Fix relative path + filename on macOs (thanks to @cmandlbaur)
  • Update travis.yml, editorconfig and package.json
  • Add new badges (Coveralls, Snyk)

0.0.4 Add jsonlint

  • Analyse json files and show exactly wehre is the error

0.0.1 Initial release

  • initial code

License

MIT 2017 David Dias

Package Rankings
Top 5.23% on Npmjs.org
Badges
Extracted from project README
Build Status Coverage Status Dependencies Known Vulnerabilities npm module downloads per month NPM