prettier-diff
`git diff` wrapper for semantic JavaScript/JSON diffs
Last updated 3 years ago .
· Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install prettier-diff 
SYNC missed versions from official npm registry.

prettier-diff

prettier-diff is a git diff wrapper that preprocesses JavaScript and JSON files to reduce the number of formatting changes that appear in the diff. This allows you to focus on the semantic changes, which is useful when viewing diffs that also have formatting changes.

JavaScript is preprocessed with prettier, and JSON is preprocessed with json-stable-stringify and json-align.

Installation

You can use yarn or npm to install prettier-diff:

yarn global add prettier-diff
# or
npm install --global prettier-diff

Usage

One-off usage

In any git repository, just use prettier-diff instead of git diff:

# instead of
git diff head^^
# do this
prettier-diff head^^

Behind the scenes, prettier-diff temporarily modifies the .git/config and .git/info/attributes files to set up the preprocessing by defining a textconv for all files.

git diff integration

To always use prettier-diff as part of git diff in a given repository, you can run the following:

git config diff.prettier.textconv textconv-prettier

echo '*.js diff=prettier' >> .gitattributes
echo '*.json diff=prettier' >> .gitattributes

Now, git diff will automatically run prettier-diff on your JS/JSON files, and it plays well with the other git diff options like --ignore-all-space, as well as diff-so-fancy. See here for more information: textconv

Examples

For example, this repository contains a large commit that rewrote most of its code with prettier-standard, and also renames a variable. You can see the commit on GitHub here: 8cc0119

With prettier-diff, only the renaming is shown:

prettier-diff 8cc0119^ 8cc0119 --color | diff-so-fancy

screenshot of

Current Tags

  • 0.0.16                                ...           latest (3 years ago)

16 Versions

  • 0.0.1                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.7                                ...           5 years ago
  • 0.0.8                                ...           5 years ago
  • 0.0.9                                ...           5 years ago
  • 0.0.10                                ...           5 years ago
  • 0.0.11                                ...           5 years ago
  • 0.0.12                                ...           5 years ago
  • 0.0.13                                ...           5 years ago
  • 0.0.14                                ...           5 years ago
  • 0.0.15                                ...           4 years ago
  • 0.0.16                                ...           3 years ago
Maintainers (1)
Dependencies (9)

Copyright © npmmirror.com | 浙ICP备15033595号-63 |