1.0.2 • Published 4 years ago
sync-json v1.0.2
sync-json
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 synchronisedInstallation
npm install -g sync-jsonAlternatively it can be installed locally as a dependency with
npm install --save-dev sync-jsonUsage
CLI
$ 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]Module
If installed as a dependency sync-json could be required as a module that exposes a single function syncJson:
const syncJson = require('sync-json')API
- syncJson(src, dst[, props], callback)
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 wholesrcobject. 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){ ... });License
Copyright (c) 2016 Josan Coba. Licensed under the MIT License (see LICENSE).