Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh
Created January 14, 2022 08:59
Show Gist options
  • Save OliverJAsh/18aa530b1606346d00ac89b72d38cdc1 to your computer and use it in GitHub Desktop.
Save OliverJAsh/18aa530b1606346d00ac89b72d38cdc1 to your computer and use it in GitHub Desktop.
prettier-diff
#!/bin/bash
# Exit immediately if a command exits with a non-zero status, amongst other improvements
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -eux
#
# Example usage:
# ./prettier-diff.sh --no-index my-minified-file-before.js my-minified-file-after.js
#
# Inspired by https://github.com/josephfrazier/prettier-diff but this script is a lot simpler
# because it doesn't need to (dangerously) modify git files.
#
cat $2 | prettier --parser babel > a.js
cat $3 | prettier --parser babel > b.js
set +e
git diff $1 a.js b.js
set -e
rm -rf a.js b.js
@OliverJAsh
Copy link
Author

Amazing, thanks Paul!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment