58 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
args=""
pkgs=""
for i in "$@"; do
if [[ "$i" == "playwright" ]]; then
args="${args} ${PLAYWRIGHT_TGZ}"
pkgs="${pkgs} playwright"
elif [[ $i == "playwright-core" ]]; then
args="${args} ${PLAYWRIGHT_CORE_TGZ}"
pkgs="${pkgs} playwright-core"
elif [[ $i == "playwright-firefox" ]]; then
args="${args} ${PLAYWRIGHT_FIREFOX_TGZ}"
pkgs="${pkgs} playwright-firefox"
elif [[ $i == "playwright-chromium" ]]; then
args="${args} ${PLAYWRIGHT_CHROMIUM_TGZ}"
pkgs="${pkgs} playwright-chromium"
elif [[ $i == "playwright-webkit" ]]; then
args="${args} ${PLAYWRIGHT_WEBKIT_TGZ}"
pkgs="${pkgs} playwright-webkit"
elif [[ $i == "@playwright/test" ]]; then
args="${args} ${PLAYWRIGHT_TEST_TGZ}"
pkgs="${pkgs} @playwright/test"
elif [[ $i == "-"* ]]; then
args="${args} $i"
else
echo "ERROR: cannot install package $i using npm_i. Use regular npm instead"
fi
done
npm install $args 2>&1
SCRIPT=$(cat <<EOF
const path = require('path');
const fs = require('fs');
const packages = process.argv.slice(1);
console.log('Verifying local installation of:', packages.join(', '));
for (const package of packages) {
const expectedDir = process.env.EXPECTED_NODE_MODULES_PARENT;
const packageJsonPath = path.join(path.dirname(require.resolve(package)), 'package.json');
if (!packageJsonPath.startsWith(expectedDir)) {
console.error('Local resolution of package failed. Package:', package, 'Expected:', expectedDir, 'Got:', path.dirname(packageJsonPath));
process.exit(1);
}
const expectedVersion = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')).version;
if (expectedVersion !== process.env.PLAYWRIGHT_VERSION_UNDER_TEST) {
console.error('Version of local package did not match expectation. Package:', package, 'Expected:', expectedVersion, 'Got:', process.env.PLAYWRIGHT_VERSION_UNDER_TEST);
process.exit(1);
}
}
console.log('Confirmed local installation of:', packages.join(', '));
EOF
)
node -e "${SCRIPT}" $pkgs