-
Notifications
You must be signed in to change notification settings - Fork 121
/
bulk-npm.sh
executable file
·74 lines (63 loc) · 1.5 KB
/
bulk-npm.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# number of arguments... $#
echo "Maintain npm packages across multiple projects - A script to save time"
echo "supported commands: npm outdated, npm update, npm i [options] [package], npm r [package]"
echo "IF RUNNING ON WINDOWS PLEASE ENSURE YOU INTEGRATE GIT BASH TO CMD SHELL WHEN INSTALLING GIT ON WINDOWS"
echo
PS3="Please enter your choice: "
options=("Confirm All" "Confirm Single" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Confirm Single")
echo "Confirm files individually"
break
;;
"Confirm All")
echo "Confirm all files"
break
;;
"Quit")
exit 0
;;
*) echo "invalid option $REPLY";;
esac
done
echo
declare -a PACKAGES=(
"/cookbook"
"/jscommon"
"/express-template"
"/express-template/apps"
"/vue-antd-template"
"/vue-antd-template/src/apps"
)
BASEPATH=`cd .. && pwd`
# BASEPATH=`pwd`
# TO IMPROVE GET CHOICE TO CHOOSE INDIVIDUALLY OR DO FOR ALL
echo "Running npm ${*}..."
echo
for package in "${PACKAGES[@]}"
do
DOIT="Y"
packagePath="${BASEPATH}${package}"
if [ "$opt" == "Confirm Single" ]; then
echo -n "Run for ${packagePath} (y/n)? "
read DOIT
fi
if [ "$DOIT" != "${DOIT#[Yy]}" ]; then
# or do whatever with individual element of the array
echo "Running for... ${packagePath}"
cd $packagePath
if [ "$*" == "update" ]; then
echo `npm $* --save`
else
echo `npm $*`
fi
else
echo "Skipped... ${packagePath}"
fi
done
# echo checking app
echo done...
read