util.merge-packages
Merges the contents of two package.json files
It attempts to combine two separate package.json
files into one, respecting as much existing content as possible including already existing dependencies and package.json
formatting.
Installation
This module uses yarn to manage dependencies and run scripts for development.
To install as an application dependency:
$ yarn add --dev util.merge-packages
To install globally (for the CLI):
$ yarn global add util.merge-packages
To build the app and run all tests:
$ yarn run all
Usage
; let dst = fs;let src = fs; // Create a new `package.json` as a stringconsole;
It allows you to do things like define scripts or dependencies that you would like to include as part of a larger project.
Merging:
results in:
CLI
The tool installs a command line version of this library to a program named pkgmerge
. It uses the following options:
pkgmerge --out={filename}|./out.json --f1={file1.json} --f2={file2.json}
This will take file2.json (f2), merge it into file1.json (f1) and save the output to the filename given in the --out
parameter.
This module was inspired by the existing module @ https://github.com/izaakschroeder/package-merge. This module uses Typescript, creates typings, uses the ava test runner, and adds it to the Travis CI/CD process.