From 1171dcc56fc04753f24dcdf5b4bbc1f12d13cc42 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 29 Nov 2023 15:02:04 +0300 Subject: [PATCH] fix filebrowser tests --- filebrowser/main.test.ts | 16 +++++----------- filebrowser/run.sh | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/filebrowser/main.test.ts b/filebrowser/main.test.ts index 7541e65..ff1c2fe 100644 --- a/filebrowser/main.test.ts +++ b/filebrowser/main.test.ts @@ -31,16 +31,14 @@ describe("filebrowser", async () => { const output = await executeScriptInContainer(state, "alpine"); expect(output.exitCode).toBe(0); expect(output.stdout).toEqual([ - "\u001b[0;1mInstalling filebrowser ", + "\u001B[0;1mInstalling filebrowser ", "", - "🥳 Installation comlete! ", + "🥳 Installation complete! ", "", "👷 Starting filebrowser in background... ", "", "📂 Serving /root at http://localhost:13339 ", "", - "Running 'filebrowser --noauth --root /root --port 13339' ", - "", "📝 Logs at /tmp/filebrowser.log", ]); }); @@ -53,16 +51,14 @@ describe("filebrowser", async () => { const output = await executeScriptInContainer(state, "alpine"); expect(output.exitCode).toBe(0); expect(output.stdout).toEqual([ - "\u001b[0;1mInstalling filebrowser ", + "\u001B[0;1mInstalling filebrowser ", "", - "🥳 Installation comlete! ", + "🥳 Installation complete! ", "", "👷 Starting filebrowser in background... ", "", "📂 Serving /root at http://localhost:13339 ", "", - "Running 'filebrowser --noauth --root /root --port 13339 -d .config/filebrowser.db' ", - "", "📝 Logs at /tmp/filebrowser.log", ]); }); @@ -77,14 +73,12 @@ describe("filebrowser", async () => { expect(output.stdout).toEqual([ "\u001B[0;1mInstalling filebrowser ", "", - "🥳 Installation comlete! ", + "🥳 Installation complete! ", "", "👷 Starting filebrowser in background... ", "", "📂 Serving /home/coder/project at http://localhost:13339 ", "", - "Running 'filebrowser --noauth --root /home/coder/project --port 13339' ", - "", "📝 Logs at /tmp/filebrowser.log", ]); }); diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 4755f61..c084c17 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -1,27 +1,30 @@ #!/usr/bin/env bash +# Convert templated variables to shell variables +ROOT_DIR=${FOLDER} +PORT=${PORT} +DB_PATH=${DB_PATH} +LOG_PATH=${LOG_PATH} + +# Expand ~ to $HOME +ROOT_DIR=$${ROOT_DIR/#\~/$${HOME}} + BOLD='\033[0;1m' + printf "$${BOLD}Installing filebrowser \n\n" curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash -printf "🥳 Installation comlete! \n\n" +printf "🥳 Installation complete! \n\n" printf "👷 Starting filebrowser in background... \n\n" -# Convert templated variables to shell variables -ROOT_DIR=${FOLDER} -ROOT_DIR=$${ROOT_DIR/\~/$HOME} -PORT=${PORT} -DB_PATH=${DB_PATH} -LOG_PATH=${LOG_PATH} - DB_FLAG="" if [ "$${DB_PATH}" != "filebrowser.db" ]; then DB_FLAG="-d $${DB_PATH}" fi -printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" +printf "📂 Serving %s at http://localhost:%s \n\n" "$${ROOT_DIR}" "$${PORT}" filebrowser --noauth --root "$${ROOT_DIR}" --port "$${PORT}" "$${DB_FLAG}" > "$${LOG_PATH}" 2>&1 &