gulp-config-sync
v1.0.2
Published
Synchronize version, name, description, keywords... in each config file (package.json, bower.json, component.js...).
Downloads
88
Maintainers
Readme
#gulp-config-sync
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
- Default
fields
- Default
[ 'name', 'version', 'description', 'keywords', 'repository', {from: 'contributors', to: 'authors'} ]
- Specifies the fields to be synchronized
- Default
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(''));