Merge branch 'codex/chore/pw-session-home-fallback'

This commit is contained in:
Tommaso Casaburi
2026-08-01 19:36:06 +02:00
2 changed files with 18 additions and 3 deletions
+14 -2
View File
@@ -45,8 +45,20 @@ EOF
}
playwright_cli="${PLAYWRIGHT_CLI_BIN:-playwright-cli}"
lock_root="${XDG_CACHE_HOME:-$HOME/.cache}/bitsocial"
lock_dir="${PLAYWRIGHT_RESOURCE_LOCK_DIR:-$lock_root/playwright-session.lock}"
# Resolved in order so an explicit override never depends on HOME being set:
# some sandboxes, CI runners, and test harnesses start without it.
if [ -n "${PLAYWRIGHT_RESOURCE_LOCK_DIR:-}" ]; then
lock_dir="$PLAYWRIGHT_RESOURCE_LOCK_DIR"
elif [ -n "${XDG_CACHE_HOME:-}" ]; then
lock_dir="$XDG_CACHE_HOME/bitsocial/playwright-session.lock"
elif [ -n "${HOME:-}" ]; then
lock_dir="$HOME/.cache/bitsocial/playwright-session.lock"
else
echo "pw-session: set HOME, XDG_CACHE_HOME, or PLAYWRIGHT_RESOURCE_LOCK_DIR so the lock has a home" >&2
exit 1
fi
owner_file="$lock_dir/owner"
started_file="$lock_dir/started-at"
workspace_file="$lock_dir/workspace"
+4 -1
View File
@@ -47,8 +47,11 @@ let tempDir;
const run = (...args) => {
const result = spawnSync(scriptPath, args, {
encoding: 'utf8',
// PATH and HOME are named explicitly rather than relying on spreading
// process.env, which vitest patches per environment.
env: {
...process.env,
PATH: process.env.PATH,
HOME: process.env.HOME,
PLAYWRIGHT_RESOURCE_LOCK_DIR: path.join(tempDir, 'slot.lock'),
PLAYWRIGHT_CLI_BIN: path.join(tempDir, 'fake-playwright-cli'),
PW_SESSION_POLL_SECONDS: '1',