generated from ddev/ddev-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): Add npm as an alternative package manager and add playwright…
…-init command (#15) * feat(package manager): Add npm as alternative to yarn * feat(*): Add playwright-init command * fix(install): Fix playwright-install for npm * test(*): Fix tests * docs(README): Update readme
- Loading branch information
1 parent
5ba8c87
commit dcb1941
Showing
8 changed files
with
213 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
#ddev-generated | ||
# Remove the line above if you don't want this file to be overwritten when you run | ||
# ddev get julienloizelet/ddev-playwright | ||
# | ||
# This file comes from https://github.com/julienloizelet/ddev-playwright | ||
# | ||
## Description: Init playwright in PLAYWRIGHT_TEST_DIR | ||
## Usage: playwright-init --pm [npm|yarn] | ||
## Example: "ddev playwright-init --pm yarn" | ||
|
||
function display_help() { | ||
echo "Usage: $0 --pm [yarn|npm]" | ||
echo "Example: $0 --pm yarn" | ||
exit 1 | ||
} | ||
|
||
# Default package manager is not set | ||
PACKAGE_MANAGER="" | ||
|
||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--pm) PACKAGE_MANAGER="$2"; shift ;; | ||
*) echo "Unknown parameter passed: $1"; display_help ;; | ||
esac | ||
shift | ||
done | ||
|
||
# Check if package manager is specified and valid | ||
if [[ -z "$PACKAGE_MANAGER" ]] || ! { [[ "$PACKAGE_MANAGER" == "yarn" ]] || [[ "$PACKAGE_MANAGER" == "npm" ]]; }; then | ||
echo "Warning: Package manager should be specified with --pm and be one of 'yarn' or 'npm'." | ||
echo "Defaulting to yarn" | ||
PACKAGE_MANAGER="yarn" | ||
fi | ||
|
||
cd /var/www/html || exit 1 | ||
cd "${PLAYWRIGHT_TEST_DIR}" || exit 1 | ||
|
||
export PLAYWRIGHT_BROWSERS_PATH=0 | ||
PRE="sudo -u pwuser PLAYWRIGHT_BROWSERS_PATH=0 " | ||
|
||
if [[ $PACKAGE_MANAGER == "npm" ]]; then | ||
$PRE npm init playwright@latest | ||
elif [[ $PACKAGE_MANAGER == "yarn" ]]; then | ||
$PRE yarn create playwright | ||
fi | ||
|
||
# Conditionally copy an .env file if an example file exists | ||
[ -f .env.example ] && [ ! -f .env ] && $PRE cp -n .env.example .env; exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters