diff --git a/commands/host/1x-playwright-install b/commands/host/1x-playwright-install index 54abaa6..57a6888 100755 --- a/commands/host/1x-playwright-install +++ b/commands/host/1x-playwright-install @@ -23,17 +23,25 @@ echo -e "${GREEN}Installing playwright (within DDEV):${NC}" ddev add-on get lullabot/ddev-playwright --version 0.5.0 ddev restart -[ "${DDEV_MUTAGEN_ENABLED:-}" = "true" ] && ddev mutagen sync -# Make sure we have a test/playwright-folder. -ddev exec -d /var/www/html/ "mkdir -p test/playwright" -# Empty JSON so the `ddev install-playwright` actually installs. -[ "${DDEV_MUTAGEN_ENABLED:-}" = "true" ] && ddev mutagen sync -ddev exec -d /var/www/html/test/playwright 'echo "{}" > ./package.json' +# Only create an empty package.json if it doesn't exist. +if [ ! -f "$DDEV_APPROOT/test/playwright/package.json" ]; then + [ "${DDEV_MUTAGEN_ENABLED:-}" = "true" ] && ddev mutagen sync + # Make sure we have a test/playwright-folder. + ddev exec -d /var/www/html/ "mkdir -p test/playwright" + # Empty JSON so the `ddev install-playwright` actually installs. + [ "${DDEV_MUTAGEN_ENABLED:-}" = "true" ] && ddev mutagen sync + ddev exec -d /var/www/html/test/playwright 'echo "{}" > ./package.json' +fi [ "${DDEV_MUTAGEN_ENABLED:-}" = "true" ] && ddev mutagen sync # Install playwright *inside* the ddev container (see lullabot/ddev-playwright) ddev install-playwright [ "${DDEV_MUTAGEN_ENABLED:-}" = "true" ] && ddev mutagen sync -# Use our forked starterkit https://github.com/1xINTERNET/create-dxp-playwright to scaffold. -ddev exec -d /var/www/html/test/playwright "npx --yes 1xINTERNET/create-dxp-playwright --version='~1.58' --quiet" + +if [ ! -f "$DDEV_APPROOT/test/playwright/package-lock.json" ]; then + # Use our forked starterkit https://github.com/1xINTERNET/create-dxp-playwright to scaffold. + ddev exec -d /var/www/html/test/playwright "npx --yes 1xINTERNET/create-dxp-playwright --version='~1.58' --quiet" +else + echo "Notice: because of an existing test/playwright/package-lock.js, we have NOT (re-)installed 1xINTERNET/create-dxp-playwright!" +fi