From 30c0e4ae6a644d11150208ae26ade605862ac57a Mon Sep 17 00:00:00 2001 From: NasgulNexus Date: Thu, 12 Sep 2024 11:22:58 +0200 Subject: [PATCH] test: add podman playwright --- scripts/playwright-docker.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/playwright-docker.sh b/scripts/playwright-docker.sh index 3507309..7674751 100755 --- a/scripts/playwright-docker.sh +++ b/scripts/playwright-docker.sh @@ -7,20 +7,34 @@ IMAGE_TAG="v1.45.3-jammy" # This version have to be synchronized with playwright NODE_MODULES_CACHE_DIR="$HOME/.cache/navigation-playwright-docker-node-modules" +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + run_command() { - docker run --rm --network host -it -w /work \ + $CONTAINER_TOOL run --rm --network host -it -w /work \ -v $(pwd):/work \ -v "$NODE_MODULES_CACHE_DIR:/work/node_modules" \ "$IMAGE_NAME:$IMAGE_TAG" \ /bin/bash -c "$1" } +if command_exists docker; then + CONTAINER_TOOL="docker" +elif command_exists podman; then + CONTAINER_TOOL="podman" +else + echo "Neither Docker nor Podman is installed on the system." + exit 1 +fi + if [[ "$1" = "clear-cache" ]]; then rm -rf "$NODE_MODULES_CACHE_DIR" exit 0 fi if [[ ! -d "$NODE_MODULES_CACHE_DIR" ]]; then + mkdir -p "$NODE_MODULES_CACHE_DIR" run_command 'npm ci' fi