Keep JSON files (or parts of them) in sync.
This module can be used to sync properties of config files like package.json or bower.json
$ sync-json -v --property version --source package.json app/package.json app/bower.json
Synchronising [version] from package.json...
✔ app/package.json
✔ app/bower.json
Successfully synchronised
npm install -g sync-json
Alternatively it can be installed locally as a dependency with
npm install --save-dev sync-json
$ sync-json --help
Usage: sync-json [-p <property> | -i <field>] -s <source> <dest-files...>
Files to sync:
-s, --source Source file [string] [required]
-t, --targets Target file(s) [array]
Properties to sync:
-p, --property, --properties Each property to sync from source [string]
-i, --implicit Replaces "-p". Read the properties from a field
of source
Options:
-v, --verbose Output messages on success [boolean]
-h, --help Show help [boolean]
--version Show version number [boolean]
If installed as a dependency sync-json could be required as a module that exposes a single function syncJson
:
const syncJson = require('sync-json');
Arguments:
- src
<string>
|<object>
: The path to the source JSON or a JS object. - dst
<string>
|[<string>]
: Path or array of paths to the destination files. - props
<string>
|[<string>]
: Optional. List of properties from the source object to copy to the destionation files. If not specified, it will synchronise the wholesrc
object. If specified a single<string>
it will use it as a field on source from where to read the props object. - callback
<function>
: nodejs style callback.
syncJson( 'package.json', ['app/package.json', 'app/bower.json'], ['version', 'contributors'], function(err){ ... });
Copyright (c) 2016 Josan Coba. Licensed under the MIT License (see LICENSE).