NPM package diff (pkdiff)
Compare npm package releases and tarball. Show diff between package versions in browser or as unix diff output.
Requirements:
- node > 8.6.0
- GNU diffutils (diff)
- xargs
Usage:
npm install -g pkdiff
pkdiff <new-version> <old-version>
Basic examples:
show diff in browser:
npx pkdiff react 16.11.0
npx pkdiff react@next 16.11.0
diff as JSON:
npx pkdiff react@16.12.0 16.11.0 --quite --format=json > diff.json
diff as unix Diff:
npx pkdiff react@16.12.0 16.11.0 -f diff
exclude files from diff:
npx pkdiff react@latest 16.11.0 --exclude='\.json$'
Compare local packed packages:
npx pkdiff your-package@latest ./your-packed-package.tgz
npx pkdiff ./your-packed-package1.tgz ./your-packed-package2.tgz
Output formats:
- json
- html (see Diff2html example)
- diff (UNIX diff output)
Options
-x, --exclude [string]
- exclude files (JS RegExp)-f, --format [diff|json|html]
- output format (default: "html")-o, --output [path]
- output destination (default: false)-c, --no-exit-code
- returns code 0 if found differences-q, --quite
- turn off actions log (default: false)--fast-check
- will try to find diff in any file and return result (default: false)--registry [string]
- npm registry url--prefer-offline
- npm clipreffer-offline
-h, --help
- output usage information
JS API
const hasDiff // result as "unix diff" string // if you don't logs set it to false compare // diff as json compareJSON setLogQuite} = ; /** * @param * @param * @param * @param if "false" compare function will stop on first diff and returns boolean (package equals: true or has diff: false) * @param * @param * @param * * @returns {Promise<boolean|string|undefined>}*/ // check diff between package versionsconst result = ;const result = ; // with validate functionconst result = ; // get diff as JSONconst diffJSON = ; const changedFiles = diffJSON