Skip to content

Commit a07e6f2

Browse files
committed
Make compile write the profile.d sh file
1 parent de6f556 commit a07e6f2

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

bin/compile

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,45 @@ export_env_dir() {
2121
export_env_dir
2222

2323
# modify the installation location
24-
if [ -z "$BUILDPACK_BROWSERS_INSTALL_PATH" ]; then
25-
BUILDPACK_BROWSERS_INSTALL_PATH="/browsers"
26-
fi
24+
BUILDPACK_BROWSERS_INSTALL_PATH=${BUILDPACK_BROWSERS_INSTALL_PATH:-"/browsers"}
2725

28-
if [ -z "$PLAYWRIGHT_BUILDPACK_BROWSERS" ]; then
29-
# follow format of https://github.com/playwright-community/heroku-playwright-buildpack/blob/master/bin/compile
30-
SUPPORTED_BROWSERS=${PLAYWRIGHT_BUILDPACK_BROWSERS:-chromium,firefox,webkit}
31-
fi
26+
# follow format of https://github.com/playwright-community/heroku-playwright-buildpack/blob/master/bin/compile
27+
PLAYWRIGHT_BUILDPACK_BROWSERS=${PLAYWRIGHT_BUILDPACK_BROWSERS:-chromium,firefox,webkit}
3228

3329
export PLAYWRIGHT_BROWSERS_PATH=$BUILD_DIR/$BUILDPACK_BROWSERS_INSTALL_PATH
34-
echo "-----> BROWSERS_INSTALL_PATH is $BUILDPACK_BROWSERS_INSTALL_PATH"
30+
echo "-----> BUILDPACK_BROWSERS_INSTALL_PATH is $BUILDPACK_BROWSERS_INSTALL_PATH"
3531
echo "-----> Browsers will be installed in $PLAYWRIGHT_BROWSERS_PATH"
36-
echo "-----> Installing Playwright executables (env: PLAYWRIGHT_BUILDPACK_BROWSERS) for ${SUPPORTED_BROWSERS} (formatted value for command line is '${SUPPORTED_BROWSERS//,/ }')."
37-
playwright install ${SUPPORTED_BROWSERS//,/ }
32+
echo "-----> Installing Playwright executables (env: PLAYWRIGHT_BUILDPACK_BROWSERS) for ${PLAYWRIGHT_BUILDPACK_BROWSERS} (formatted value for command line is '${PLAYWRIGHT_BUILDPACK_BROWSERS//,/ }')."
33+
playwright install ${PLAYWRIGHT_BUILDPACK_BROWSERS//,/ }
3834
echo "-----> Installation done"
3935

40-
# copy the buildpack's heroku-playwright-python-browsers-defaults.sh over to the build pack
41-
cat ./heroku-playwright-python-browsers-defaults.sh
42-
cp ./heroku-playwright-python-browsers-defaults.sh $BUILD_DIR/.profile.d/heroku-playwright-python-browsers-defaults.sh
36+
# export the file path as a ENV
37+
# this is meant to be copied over to the $BUILD_DIR under .profile.d/heroku-playwright-python-browsers-defaults.sh and then run
38+
39+
PROFILE_D_FILE=$BUILD_DIR/.profile.d/heroku-playwright-python-browsers-defaults.sh
40+
41+
if [ "$PLAYWRIGHT_BUILDPACK_BROWSERS" == *"chromium"* ]; then
42+
cat <<EOF >> $PROFILE_D_FILE
43+
PATH=\${find ~+ -type f -name "chrome":-NULL}
44+
echo "----> CHROMIUM_EXECUTABLE_PATH is \$PATH"
45+
export CHROMIUM_EXECUTABLE_PATH=\$PATH
46+
EOF
47+
fi
48+
49+
if [ "$PLAYWRIGHT_BUILDPACK_BROWSERS" == *"firefox"* ]; then
50+
cat <<EOF >> $PROFILE_D_FILE
51+
PATH=${find ~+ -type f -name "firefox":-NULL}
52+
echo "----> FIREFOX_EXECUTABLE_PATH is \$PATH"
53+
export FIREFOX_EXECUTABLE_PATH=\$PATH
54+
EOF
55+
fi
56+
57+
if [ "$PLAYWRIGHT_BUILDPACK_BROWSERS" == *"webkit"* ]; then
58+
cat <<EOF >> $PROFILE_D_FILE
59+
PATH=${find ~+ -type f -name "pw_run.sh":-NULL} # see https://github.com/microsoft/playwright/issues/2923
60+
echo "----> WEBKIT_EXECUTABLE_PATH is \$PATH"
61+
export WEBKIT_EXECUTABLE_PATH=\$PATH
62+
EOF
63+
fi
64+
65+
cat $PROFILE_D_FILE

bin/heroku-playwright-python-browsers-defaults.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)