From df23e7269b81f3ed360ff7afc27db5b287153511 Mon Sep 17 00:00:00 2001 From: Radiane Date: Mon, 4 Aug 2025 15:51:26 +0200 Subject: [PATCH] Made so script can be launched from anywhere Cuz i wanted to use it as a desktop shortcut ! --- start.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/start.sh b/start.sh index dfe59da..499157d 100644 --- a/start.sh +++ b/start.sh @@ -1,4 +1,9 @@ #!/bin/bash + +DIR=$(dirname "$0") + +cd "$SDIR" || exit + pause() { read -p "Press any key to exit . . ." exit @@ -12,16 +17,21 @@ if ! [ -d "node_modules" ]; then fi fi -if ! [ -e "node" ]; then - echo "Detected local Node.js executable, attempting to use it..." - node src/app.js +if ! command -v node &> /dev/null; then + echo "Node.js is not installed. Please install Node.js to run this script." + pause else - echo "Did not detect local Node.js executable, attempting to use `npm`..." - npm start + if [ -x "node" ]; then + echo "Detected local Node.js executable, attempting to use it..." + ./node src/app.js + else + echo "Did not detect local Node.js executable, attempting to use `npm`..." + npm start + fi fi if [ $? -ne 0 ]; then - if [ "$1" -eq "--keep-on-error" ]; then + if [ "$1" = "--keep-on-error" ]; then pause fi fi