-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyarn.sh
executable file
·66 lines (58 loc) · 1.17 KB
/
yarn.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
#!/bin/bash
RED='\033[0;31m'
SET='\033[0m'
function display_help() {
echo "Usage: $0 [option...]"
echo
echo " -h, --help Show this help message"
echo " -v, --version Show script version"
echo " -f, --force Force delete .yarnrc.yml without asking"
echo
}
function display_version() {
echo "1.0"
}
function delete_yarnrc() {
if [ -f .yarnrc.yml ]; then
if [ "$FORCE_DELETE" = true ]; then
rm .yarnrc.yml
else
read -p "Do you really want to delete your current .yarnrc.yml? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
rm .yarnrc.yml
else
exit 1
fi
fi
fi
}
# Parse command line arguments
FORCE_DELETE=false
while [[ "$1" != "" ]]; do
case $1 in
-h | --help )
display_help
exit
;;
-v | --version )
display_version
exit
;;
-f | --force )
FORCE_DELETE=true
;;
* )
echo "Invalid option: $1"
display_help
exit 1
esac
shift
done
# Main script
corepack enable
delete_yarnrc
yarn set version stable
yarn set version 4.5.3 --yarn-path
yarn config set nodeLinker node-modules
yarn