JSPM

  • Created
  • Published
  • Downloads 472189
  • Score
    100M100P100Q186018F
  • License ISC

The registry diff

Package Exports

  • libnpmdiff

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (libnpmdiff) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

libnpmdiff

npm version license GitHub Actions Coverage Status

The registry diff lib.

Table of Contents

Example

const libdiff = require('libnpmdiff')

const patch = await libdiff({
  a: 'abbrev@1.1.0',
  b: 'abbrev@1.1.1'
})
console.log(
  patch
)

Returns:

diff --git a/package.json b/package.json
index v1.1.0..v1.1.1 100644
--- a/package.json	
+++ b/package.json	
@@ -1,6 +1,6 @@
 {
   "name": "abbrev",
-  "version": "1.1.0",
+  "version": "1.1.1",
   "description": "Like ruby's abbrev module, but in js",
   "author": "Isaac Z. Schlueter <i@izs.me>",
   "main": "abbrev.js",

Install

$ npm install libnpmdiff

Contributing

The npm team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide outlines the process for community interaction and contribution. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.

All participants and maintainers in this project are expected to follow the npm Code of Conduct, and just generally be excellent to each other.

Please refer to the Changelog for project history details, too.

Happy hacking!

API

> libnpmdif({ a, b }, [opts]) -> Promise<String>

Fetches the registry tarballs and compare files between a spec a and spec b. npm spec types are usually described in <pkg-name>@<version> form but multiple other types are alsos supported, for more info on valid specs take a look at npm-package-arg.

If only spec a is provided, then it's going to try and compare that specified spec against the current project directory in the local file system (cwd may be set via opts.prefix option).

Options:

  • color <Boolean>: Should add ANSI colors to string output? Defaults to false.
  • tagVersionPrefix <Sring>: What prefix should be used to define version numbers. Defaults to v
  • prefix <String>: The path to use as current working directory if trying to read from local file system when using only a single comparison parameter a. Defaults to ..
  • ...cache, registry and other common options accepted by pacote
  • diffOpts <Object>: Object containing extra options on how to format the diff patch output:
    • context <Number>: How many lines of code to print before/after each diff. Defaults to 3.
    • files <Array<String>>: If set only prints patches for the files listed in this array (also accepts globs). Defaults to undefined.
    • ignoreWhitespace <Boolean>: Whether or not should ignore changes in whitespace (very useful to avoid indentation changes extra diff lines). Defaults to false.
    • nameOnly <Boolean>: Prints only file names and no patch diffs. Defaults to false.
    • noPrefix <Boolean>: If true then skips printing any prefixes in filenames. Defaults to false.
    • srcPrefix <String>: Prefix to be used in the filenames from a. Defaults to a/.
    • dstPrefix <String>: Prefix to be used in the filenames from b. Defaults to b/.
    • text <Boolean>: Should treat all files as text and try to print diff for binary files. Defaults to false.

LICENSE

ISC