Prompt step by step for the missing base image, ISO, npm deps and Chromium
Offer to build the base QCOW2, download the ISO, run npm ci and install Chromium (from the npmmirror mirror by default). Let Playwright locate its own Chromium so macOS works. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b37d1e002c
commit
1476b4a3de
3 files changed
+77
-13
No files matched your search
@@ -5,12 +5,11 @@
|
||||
// Usage: node get-windows-iso-url.js [--arch x64|arm64] [--lang NAME]
|
||||
// Environment:
|
||||
// PLAYWRIGHT_CORE playwright-core directory (default: node_modules here)
|
||||
// CHROME_PATH Chromium executable (default: newest one in ~/.cache/ms-playwright)
|
||||
// CHROME_PATH Chromium executable (default: the one Playwright installed)
|
||||
// The URL expires after about 24 hours and may be bound to the IP that
|
||||
// requested it. Only the URL goes to stdout; logs go to stderr.
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
@@ -28,8 +27,7 @@ Options:
|
||||
|
||||
Environment:
|
||||
PLAYWRIGHT_CORE playwright-core directory (default: node_modules here)
|
||||
CHROME_PATH Chromium executable (default: newest one in
|
||||
~/.cache/ms-playwright)
|
||||
CHROME_PATH Chromium executable (default: the one Playwright installed)
|
||||
|
||||
Examples:
|
||||
node get-windows-iso-url.js --arch x64 --lang "Chinese Simplified"
|
||||
@@ -60,17 +58,20 @@ function findPlaywright() {
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
function findChrome() {
|
||||
if (process.env.CHROME_PATH) return process.env.CHROME_PATH;
|
||||
const root = path.join(os.homedir(), '.cache/ms-playwright');
|
||||
const dirs = fs.existsSync(root) ? fs.readdirSync(root).filter(d => /^chromium-\d+$/.test(d)).sort() : [];
|
||||
if (!dirs.length) { console.error('Chromium not found: set CHROME_PATH or run npx playwright-core install chromium'); process.exit(2); }
|
||||
return path.join(root, dirs.pop(), 'chrome-linux64/chrome');
|
||||
// CHROME_PATH wins; otherwise Playwright picks the Chromium it installed (in
|
||||
// its own per-OS cache, PLAYWRIGHT_BROWSERS_PATH if set).
|
||||
function launchOptions(chromium) {
|
||||
if (process.env.CHROME_PATH) return { executablePath: process.env.CHROME_PATH, headless: true };
|
||||
if (!fs.existsSync(chromium.executablePath())) {
|
||||
console.error('Chromium not found: set CHROME_PATH or run npx playwright-core install chromium');
|
||||
process.exit(2);
|
||||
}
|
||||
return { headless: true };
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const { chromium } = require(findPlaywright());
|
||||
const browser = await chromium.launch({ executablePath: findChrome(), headless: true });
|
||||
const browser = await chromium.launch(launchOptions(chromium));
|
||||
try {
|
||||
const ctx = await browser.newContext({
|
||||
locale: 'en-US',
|
||||
|
||||
Reference in new issue
Block a user