Last active
April 12, 2016 09:09
-
-
Save PieterScheffers/3080dff812a67a464757 to your computer and use it in GitHub Desktop.
Shell - file changed
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
| MD5_FILE="md5_file" | |
| FILE="somefile" | |
| # create MD5 of somefile | |
| md5=`md5 $FILE | cut -d'=' -f2 | tr -d " "` | |
| # Write md5 to file | |
| md5 > $MD5_FILE | |
| # Get MD5 from file | |
| md5=`cat $MD5_FILE` | |
| ################################################# | |
| newmd5=`md5 $FILE | cut -d'=' -f2 | tr -d " "` | |
| if [ -f $MD5_FILE ]; then | |
| md5=`cat $MD5_FILE` | |
| if [ $newmd5 = $md5 ]; then | |
| echo "md5 match, so 'npm install' will NOT be run" | |
| else | |
| echo "$md5 doesn't match $newmd5. Running 'npm install'... " | |
| newmd5 > $MD5_FILE | |
| npm run install | |
| fi; | |
| else | |
| echo "$MD5_FILE doesn't exist. Running 'npm install'... " | |
| newmd5 > $MD5_FILE | |
| npm run install | |
| fi | |
| ############################################################### | |
| OLDMD5File=".package.json.md5" | |
| newmd5=`md5sum package.json | cut -f 1 -d " "` | |
| runnpm=true | |
| if [ -f $OLDMD5File ]; then | |
| oldmd5=`cat $OLDMD5File` | |
| if [ $newmd5 = $oldmd5 ]; then | |
| echo "\n==== md5's match, so 'npm install' will NOT be run ====" | |
| runnpm=false | |
| fi; | |
| fi | |
| if [ "$runnpm" = true ] ; then | |
| echo "\n==== Disabling progressbar on npm install ====" | |
| # https://github.com/npm/npm/issues/11283 | |
| npm set progress=false | |
| echo "\n==== Installing npm packages ====" | |
| npm install | |
| echo "\n==== Writing mp5 of package.json to $OLDMD5File ====" | |
| echo "$newmd5" > $OLDMD5File | |
| fi | |
| ################################################################# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment