Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
README.md103 linesDownload Raw Back to libnpmdiff
1# libnpmdiff
2
3[![npm version](https://img.shields.io/npm/v/libnpmdiff.svg)](https://npm.im/libnpmdiff)
4[![license](https://img.shields.io/npm/l/libnpmdiff.svg)](https://npm.im/libnpmdiff)
5[![CI - libnpmdiff](https://github.com/npm/cli/actions/workflows/ci-libnpmdiff.yml/badge.svg)](https://github.com/npm/cli/actions/workflows/ci-libnpmdiff.yml)
6The registry diff lib.
7
8## Table of Contents
9
10* [Example](#example)
11* [Install](#install)
12* [Contributing](#contributing)
13* [API](#api)
14* [LICENSE](#license)
15
16## Example
17
18```js
19const libdiff = require('libnpmdiff')
20
21const patch = await libdiff([
22  'abbrev@1.1.0',
23  'abbrev@1.1.1'
24])
25console.log(
26  patch
27)
28```
29
30Returns:
31
32```patch
33diff --git a/package.json b/package.json
34index v1.1.0..v1.1.1 100644
35--- a/package.json
36+++ b/package.json
37@@ -1,6 +1,6 @@
38 {
39   "name": "abbrev",
40-  "version": "1.1.0",
41+  "version": "1.1.1",
42   "description": "Like ruby's abbrev module, but in js",
43   "author": "Isaac Z. Schlueter <i@izs.me>",
44   "main": "abbrev.js",
45
46```
47
48## Install
49
50`$ npm install libnpmdiff`
51
52### Contributing
53
54The npm team enthusiastically welcomes contributions and project participation!
55There's a bunch of things you can do if you want to contribute!
56The [Contributor Guide](https://github.com/npm/cli/blob/latest/CONTRIBUTING.md) outlines the process for community interaction and contribution.
57Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.
58
59All participants and maintainers in this project are expected to follow the [npm Code of Conduct](https://docs.npmjs.com/policies/conduct), and just generally be excellent to each other.
60
61Please refer to the [Changelog](CHANGELOG.md) for project history details, too.
62
63Happy hacking!
64
65### API
66
67#### `> libnpmdif([ a, b ], [opts]) -> Promise<String>`
68
69Fetches the registry tarballs and compare files between a spec `a` and spec `b`.
70**npm** spec types are usually described in `<pkg-name>@<version>` form but multiple other types are also supported, for more info on valid specs take a look at [`npm-package-arg`](https://github.com/npm/npm-package-arg).
71
72**Options**:
73
74- `color <Boolean>`: Should add ANSI colors to string output?
75  Defaults to `false`.
76- `tagVersionPrefix <String>`: What prefix should be used to define version numbers.
77  Defaults to `v`
78- `diffUnified <Number>`: How many lines of code to print before/after each diff.
79  Defaults to `3`.
80- `diffFiles <Array<String>>`: If set only prints patches for the files listed in this array (also accepts globs).
81  Defaults to `undefined`.
82- `diffIgnoreAllSpace <Boolean>`: Whether or not should ignore changes in whitespace (very useful to avoid indentation changes extra diff lines).
83  Defaults to `false`.
84- `diffNameOnly <Boolean>`: Prints only file names and no patch diffs.
85  Defaults to `false`.
86- `diffNoPrefix <Boolean>`: If true then skips printing any prefixes in filenames.
87  Defaults to `false`.
88- `diffSrcPrefix <String>`: Prefix to be used in the filenames from `a`.
89  Defaults to `a/`.
90- `diffDstPrefix <String>`: Prefix to be used in the filenames from `b`.
91  Defaults to `b/`.
92- `diffText <Boolean>`: Should treat all files as text and try to print diff for binary files.
93  Defaults to `false`.
94- ...`cache`, `registry`, `where` and other common options accepted by [pacote](https://github.com/npm/pacote#options)
95
96Returns a `Promise` that fulfills with a `String` containing the resulting patch diffs.
97
98Throws an error if either `a` or `b` are missing or if trying to diff more than two specs.
99
100## LICENSE
101
102[ISC](./LICENSE)
103 
codekingpro/portable-devtools · Team Ai