File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 22set -e
33
44VERSION=" ${1} "
5+ INSTALL_DIR=" ${HOME} /.dcode"
6+
57
68if [ -z " $VERSION " ]; then
79 VERSION=$( curl -s https://api.github.com/repos/we-dcode/dcli/releases/latest | grep ' "tag_name":' | sed -E ' s/.*"([^"]+)".*/\1/' )
810fi
911
12+ if [ -x " $INSTALL_DIR /dcli" ]; then
13+ INSTALLED_VERSION=$( " $INSTALL_DIR /dcli" -v 2> /dev/null | sed -nE ' s/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' )
14+ if [ " $INSTALLED_VERSION " = " ${VERSION} " ]; then
15+ echo " dcli $INSTALLED_VERSION is already up to date in $INSTALL_DIR ."
16+ exit 0
17+ fi
18+ fi
19+
1020OS=" $( uname | tr ' [:upper:]' ' [:lower:]' ) "
1121ARCH=" $( uname -m) "
1222
@@ -17,10 +27,10 @@ if [[ "$ARCH" == "arm64" || "$ARCH" == "aarch64" ]]; then ARCH="arm64"; fi
1727URL=" https://github.com/we-dcode/dcli/releases/download/$VERSION /dcli_${VERSION} _${OS} _${ARCH} .tar.gz"
1828
1929echo " 📦 Downloading dcli $VERSION for $OS /$ARCH ..."
20- mkdir -p ~ /.dcode
21- curl -sL " $URL " | tar -xz -C ~ /.dcode
30+ mkdir -p ${INSTALL_DIR}
31+ curl -sL " $URL " | tar -xz -C ${INSTALL_DIR}
2232
23- chmod +x ~ /.dcode /dcli
33+ chmod +x ${INSTALL_DIR} /dcli
2434
25- echo " ✅ Installed to ~/.dcode /dcli"
35+ echo " ✅ Installed to ${INSTALL_DIR} /dcli"
2636echo " 👉 Add to PATH: export PATH=\"\$ HOME/.dcode:\$ PATH\" "
You can’t perform that action at this time.
0 commit comments