If you’ve never heard of tenosynovitis, you don’t have to worry about it. I have tenosynovitis for 3 years, especially recently, every night when lying on the bed to rest, you can obviously feel the wrist faint pain. Tenosynovitis is nothing serious, but it hurts like hell. This is one of the reasons why there has been no more writing for so long.

Recently, I accidentally saw my code submission records for nearly a year, and found that, on average, dozens of commit times per week. Every mechanical git add, git commit, git push manually typed commands, I don’t feel anything wrong, but the amount of commit records throughout the year is still very large. I was wondering if I could reduce the repetitive routine of Git commands and improve the development efficiency. So there’s an upgrade to the existing scaffolding, a single command that takes care of NPM run push ‘*****’ and relieves tendon sheath pressure.

How about our project form, each activity, each product is an independent project, I updated the new scaffolding, the new project can be directly used. The old project needed to manually add configuration commands and files, so I wrote a shell script and the old scaffold could be upgraded with one click.

New scaffolding is used out of the box

One line of command:

npm run push '*****'
Copy the code

Replace the original command:

git add .
git commit -m '*****'
git push 
Copy the code

Old scaffolding one-click upgrade

Sh <(curl -s -l HTTPS :/****/ autogit. sh) HTTPS :/****/ autogit. sh Static resource path of the script.

If code conflicts occur or other commit or push failures occur, handle them manually.

The autogit.sh script you want to know about:

npm i shelljs -D touch autoPush.js echo 'const shell = require("shelljs"); ' > autoPush.js echo 'const { which, exec, echo, exit } = shell; ' >> autoPush.js echo 'if (! which("git")) {' >> autoPush.js echo ' echo("Sorry, this script requires git"); ' >> autoPush.js echo ' exit(1); ' >> autoPush.js echo '}' >> autoPush.js echo 'exec(`git pull`); ' >> autoPush.js echo 'const commitDesc = process.argv[2] || "auto-commit"; ' >> autoPush.js echo 'if (exec("git add .").code ! == 0) {' >> autoPush.js echo ' echo("Error: Git add failed"); ' >> autoPush.js echo ' exit(1); ' >> autoPush.js echo '}' >> autoPush.js echo 'if (exec(`git commit -am "${commitDesc}"`).code ! == 0) {' >> autoPush.js echo ' if (exec("git push").code ! == 0) {' >> autoPush.js echo ' echo("Error: Git push failed"); ' >> autoPush.js echo ' exit(1); ' >> autoPush.js echo ' } else {' >> autoPush.js echo ' echo("Error: Git commit failed"); ' >> autoPush.js echo ' exit(1); ' >> autoPush.js echo ' }' >> autoPush.js echo '}' >> autoPush.js echo 'exec(`git pull`); ' >> autoPush.js echo 'if (exec("git push").code ! == 0) {' >> autoPush.js echo ' echo("Error: Git push failed"); ' >> autoPush.js echo ' exit(1); ' >> autoPush.js echo '}' >> autoPush.js sed -i "" "8 a\ \ \ \ \ \"push\": \"node ./autoPush.js\", " package.jsonCopy the code

This shortcut command is a one-line command instead of a three-line command. After getting used to it, it is easy to forget the basic command. Therefore, the quick submission of Git code is not mandatory for students in the group to use it.