Created
          January 14, 2022 08:59 
        
      - 
      
- 
        Save OliverJAsh/18aa530b1606346d00ac89b72d38cdc1 to your computer and use it in GitHub Desktop. 
    prettier-diff
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/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 | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
instead of writing to
a.jsandb.js, you might consider usingmktempto create temp files. That way they aren't local and you don't need to worry about cleaning them up.