Reputation:
I'm using EncloseJS to turn my javascript code in executable binary , but I just want to make it into production, for this I created a file /hooks/build-for-production
, with the following content:
#!/usr/bin/env bash
npm install
gulp build
enclose --loglevel info -o ./executable dist/index.js --config config.js
rm !(executable)
So, i would like to confirm if the user wants delete everything except the executable file. Something like:
"Do you want remove everything?"
, and if the user answers is true, delete everything, but if there is uncommited stuffs, just abort.
Is this possible? How check uncommited stuffs??
Also.. i would like to know if what I 'm doing is a good practice, and if it isn't, how should i do?
Thanks.
Upvotes: 0
Views: 25
Reputation: 44370
You can use git diff --exit-code
which return nonzero if there are any changes:
echo -n "Do you want remove everything? (y/n)"
read remove
if [[ $(git diff --exit-code) -eq 0 ]];then
# have no any uncommitted stuff
else
# have some uncommitted stuff
if echo "$remove" | grep -iq "^y";then
echo "Remove all stuff"
else
# do other
fi
fi
Upvotes: 1