Last active
February 28, 2021 21:13
-
-
Save iandark/5245faab14608a2e167b6f6b28965e42 to your computer and use it in GitHub Desktop.
Clone a repo and update your package.json and lock files in origin
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 | |
| # Because of cd inside script exec with ./ will not work. To exec this you can use . scriptname.sh or source scriptname.sh | |
| # Do not use the exit command because it then closes your connection | |
| # To use this you might update your npm to latest | |
| updatePackage() { | |
| repoUrl="$1" | |
| repoUrlToRemove="/$2/" | |
| git clone "$repoUrl" | |
| if [ "" = "$repoUrlToRemove" ] | |
| then | |
| repoFolder="${repoUrl/$repoUrlToRemove/}" | |
| repoFolder="${repoFolder//\//}" | |
| repoFolder="${repoFolder/.git/}" | |
| else | |
| repoFolder="${repoUrl#*/}" | |
| repoFolder="${repoFolder/.git/}" | |
| fi | |
| dirAtual="$PWD" | |
| cd "$dirAtual/$repoFolder/" | |
| ncu -u | |
| yarn install | |
| npm install | |
| git add . | |
| git commit -m "fix: Update package.json and lock files" | |
| git push | |
| git log --name-status HEAD^..HEAD | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment