Added exiting on error

This commit is contained in:
Kallum Jones 2022-08-09 18:56:14 +01:00
parent e4adeb78db
commit 2010b8dec9
No known key found for this signature in database
GPG Key ID: D7F4589C4D7F81A9

View File

@ -31,12 +31,12 @@ then
exit exit
fi fi
rm -rf "$DOWNLOAD_DIR" rm -rf "$DOWNLOAD_DIR" || exit
mkdir -p "$DOWNLOAD_DIR" mkdir -p "$DOWNLOAD_DIR" || exit
# Verify compatible version of node is installed # Verify compatible version of node is installed
info "Verifying node verison..." info "Verifying node verison..."
NODE_VERSION_STR=$(node --version) NODE_VERSION_STR=$(node --version) || exit
if [[ "$?" -eq 127 ]] if [[ "$?" -eq 127 ]]
then then
error "Node does not appear to be installed. Please install Node version $MIN_NODE_VERSION or higher" error "Node does not appear to be installed. Please install Node version $MIN_NODE_VERSION or higher"
@ -60,25 +60,25 @@ git clone "https://hogwarts.bits.team/git/Bits/mod-manager.git" "$DOWNLOAD_DIR"
# Compile # Compile
info "Compiling..." info "Compiling..."
cd "$DOWNLOAD_DIR" || exit cd "$DOWNLOAD_DIR" || exit
npm install --save npm install --save || exit
npm install -g @vercel/ncc npm install -g @vercel/ncc || exit
npx tsc npx tsc || exit
ncc build build/ts/mod-manager.js -o build/flat ncc build build/ts/mod-manager.js -o build/ || exit
# Install # Install
info "Installing..." info "Installing..."
rm -rf "$INSTALL_DIR" rm -rf "$INSTALL_DIR" || exit
mkdir -p "$INSTALL_DIR" mkdir -p "$INSTALL_DIR" || exit
cp -r build/flat/* "$INSTALL_DIR" cp -r build/flat/* "$INSTALL_DIR" || exit
# Creating executable # Creating executable
info "Creating executable..." info "Creating executable..."
echo "node $INSTALL_DIR/index.js \$\@" > $BINARY_PATH echo "node $INSTALL_DIR/index.js \$\@" > $BINARY_PATH || exit
chmod +x $BINARY_PATH chmod +x $BINARY_PATH || exit
# Cleaning up # Cleaning up
info "Cleaning up..." info "Cleaning up..."
rm -rf "$DOWNLOAD_DIR" rm -rf "$DOWNLOAD_DIR" || exit
success "Successfully installed mod-manager. Try mod-manager -h to learn more!" success "Successfully installed mod-manager. Try mod-manager -h to learn more!"