-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathup.pkg
More file actions
executable file
·54 lines (44 loc) · 1.86 KB
/
up.pkg
File metadata and controls
executable file
·54 lines (44 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
clear
fileName=package.json
keyName=version
packageName=name
if test -e $fileName
then
echo "------------------------------------------------------"
echo "If you are not logged in to npm registry, login first and then run this script!"
value=$(grep $keyName $fileName | cut -d ":" -f2-)
pName=$(grep $packageName $fileName | cut -d ":" -f2-)
echo "Package: " $pName
echo "Current package version: " $value
echo "What kind of version do you want?"
echo " 1) MAJOR"
echo " 2) MINOR"
echo " 3) PATCH"
echo " 4) RESET (this will make the version=1.0.0)"
echo "------------------------------------------------------"
echo "You can select one option to do something or type anything else to exit..."
read -p "Select one option : " n
echo "------------------------------------------------------"
case $n in
1) npm version major --no-git-tag-version --silent;;
2) npm version minor --no-git-tag-version --silent;;
3) npm version patch --no-git-tag-version --silent;;
4) npm unpublish $packageName@1.0.0 | npm version '1.0.0' --no-git-tag-version --silent;;
*) echo -e "\nOk, if this is what you want, then I exit here!\nWhen you need me, run the script again and choose one of the above!\n";;
esac
newValue=$(grep $keyName $fileName | cut -d ":" -f2-)
if test $value = $newValue
then
echo "Package version not changed! Version is: " $value
echo "------------------------------------------------------"
else
echo "New package version is: " $newValue
npm publish
echo "------------------------------------------------------"
fi
else
echo "------------------------------------------------------"
echo "package.json not found. Run npm init first"
echo "------------------------------------------------------"
fi