copy-partial-json

A simple script to copy portions of a json document from one file to another

Usage no npm install needed!

<script type="module">
  import copyPartialJson from 'https://cdn.skypack.dev/copy-partial-json';
</script>

README

copy-partial-json

A simple script to copy portions of a json document from one file to another

npm Build Status NPM Typescript codecov

To copy the version, name and dependency list from a root package.json to child packages:

$ copy-partial-json -s package.json -t one/package.json -t two/package.json -k version name dependencies

Using npm scripts this can be done automatically when npm version is run:

{
    "scripts": {
        "version": "copy-partial-json -s package.json -t childOne/package.json -k version name dependencies && git add childOne/package.json"
    }
}

Options

| Argument | Alias | Type | Description | |-|-|-|-| | sourceFile | s | string | The json file to copy from | | targetFile | t | string[] | The json file to copy to | | keys | k | string[] | The keys to copy. For example, 'version,name,dependencies' | | jsonIndent | i | number | The number of spaces to indent your json file by. Defaults to 4. | | help | h | boolean | Show this help text |