gulp-config-sync

1.0.2 • Public • Published

gulp-config-sync

GitHub version NPM version Build Status

Synchronize version, name, description, keywords... in each config file (package.json, bower.json, component.js...).

By default, package.json is used as the source of truth but you can specify any source and any fields you want to synchronize.

Only the fields specified are synchronized. The other fields are left untouched.

Gulp

This is a plugin for gulp 3.

Usage

Install gulp-config-sync as a development dependency

$ npm install gulp-config-sync --save-dev

In your gulpfile.js

// import plugin
var sync = require('gulp-config-sync');
 
gulp.task('sync', function() {
  gulp.src(['bower.json', 'component.json'])
    .pipe(sync())
    .pipe(gulp.dest('.')); // write it to the same dir
});

You can run the new task in the termininal

$ gulp sync

Or add it to existing tasks

gulp.task('default', ['sync']);

Options

  • src

    • Default package.json
    • The path to the source.json file
  • fields

    • Default [ 'name', 'version', 'description', 'keywords', 'repository', {from: 'contributors', to: 'authors'} ]
    • Specifies the fields to be synchronized
  • space

    • Default (2 whitespaces)
    • Used for prettyprinting the result. See JSON.stringify

Example

var options = {
  src: 'source.json',
  fields: [
    'name',
    'version',
    'description',
    {
      from: 'contributors',
      to: 'authors',
    },
  ],
  space: '    ',
};
 
gulp.src('bower.json')
  .pipe(sync(options))
  .pipe(gulp.dest(''));

LICENSE

MIT

Package Sidebar

Install

npm i gulp-config-sync

Weekly Downloads

17

Version

1.0.2

License

MIT

Last publish

Collaborators

  • danlevan