*nix Programming Mammals

    sync-json

    1.0.2 • Public • Published

    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 synchronised

    Installation

    npm install -g sync-json
    

    Alternatively it can be installed locally as a dependency with

    npm install --save-dev sync-json
    

    Usage

    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:

    1. src <string> | <object>: The path to the source JSON or a JS object.
    2. dst <string> | [<string>]: Path or array of paths to the destination files.
    3. props <string> | [<string>]: Optional. List of properties from the source object to copy to the destionation files. If not specified, it will synchronise the whole src object. If specified a single <string> it will use it as a field on source from where to read the props object.
    4. 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).

    Keywords

    Install

    npm i sync-json

    DownloadsWeekly Downloads

    4,610

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • josan-coba