0.0.19 • Published 4 years ago

util.merge-packages v0.0.19

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

util.merge-packages

Merges the contents of two package.json files

build analysis code style: prettier testing NPM

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

import {merge} from 'util.mergePackages';

let dst = fs.readFileSync('package.a.json');
let src = fs.readFileSync('package.b.json');

// Create a new `package.json` as a string
console.log(merge(dst, src));

It allows you to do things like define scripts or dependencies that you would like to include as part of a larger project.

Merging:

{
    "name": "my-package",
    "dependencies": {
        "babel": "^5.2.2",
        "lodash": "^3.2.5"
    }
}
{
    "dependencies": {
        "babel": "^5.4.1",
        "eslint": "^0.22.1"
    }
}

results in:

{
    "name": "my-package",
    "dependencies": {
        "babel": "^5.4.1",
        "lodash": "^3.2.5",
        "eslint": "^0.22.1"
    }
}

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.

0.0.19

4 years ago

0.0.18

4 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago