fix: match stable extension keys in status check
This commit is contained in:
+3
-15
@@ -179,7 +179,7 @@ async function executeCode(options: {
|
|||||||
cli
|
cli
|
||||||
.command('session new', 'Create a new session and print the session ID')
|
.command('session new', 'Create a new session and print the session ID')
|
||||||
.option('--host <host>', 'Remote relay server host')
|
.option('--host <host>', 'Remote relay server host')
|
||||||
.option('--browser <name>', 'Browser to use when multiple browsers are connected')
|
.option('--browser <id>', 'Browser ID to use when multiple browsers are connected')
|
||||||
.action(async (options: { host?: string; browser?: string }) => {
|
.action(async (options: { host?: string; browser?: string }) => {
|
||||||
if (!options.host && !process.env.PLAYWRITER_HOST) {
|
if (!options.host && !process.env.PLAYWRITER_HOST) {
|
||||||
await ensureRelayServer({ logger: console, env: cliRelayEnv })
|
await ensureRelayServer({ logger: console, env: cliRelayEnv })
|
||||||
@@ -204,23 +204,11 @@ cli
|
|||||||
const shortId = extension.extensionId === 'default' ? 'default' : extension.extensionId.slice(0, 7)
|
const shortId = extension.extensionId === 'default' ? 'default' : extension.extensionId.slice(0, 7)
|
||||||
console.log(`${shortId.padEnd(7)} ${(extension.browser || 'Chrome').padEnd(7)} ${label}`)
|
console.log(`${shortId.padEnd(7)} ${(extension.browser || 'Chrome').padEnd(7)} ${label}`)
|
||||||
}
|
}
|
||||||
console.log('\nRun again with --browser <email, browser, or id>.')
|
console.log('\nRun again with --browser <id>.')
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
} else {
|
} else {
|
||||||
const byEmail = extensions.find((extension) => extension.profile?.email === options.browser)
|
selectedExtension = extensions.find((extension) => extension.extensionId === options.browser) || null
|
||||||
const byId = extensions.find((extension) => extension.extensionId === options.browser)
|
|
||||||
const byBrowser = extensions.filter((extension) => (extension.browser || 'Chrome') === options.browser)
|
|
||||||
|
|
||||||
selectedExtension = byEmail || byId || null
|
|
||||||
if (!selectedExtension && byBrowser.length === 1) {
|
|
||||||
selectedExtension = byBrowser[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selectedExtension) {
|
if (!selectedExtension) {
|
||||||
if (byBrowser.length > 1) {
|
|
||||||
console.error(`Browser name is ambiguous: ${options.browser}`)
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
console.error(`Browser not found: ${options.browser}`)
|
console.error(`Browser not found: ${options.browser}`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,9 +346,11 @@ export class PlaywrightExecutor {
|
|||||||
return (await fallback.json()) as { connected: boolean; activeTargets: number }
|
return (await fallback.json()) as { connected: boolean; activeTargets: number }
|
||||||
}
|
}
|
||||||
const data = await response.json() as {
|
const data = await response.json() as {
|
||||||
extensions: Array<{ extensionId: string; activeTargets: number }>
|
extensions: Array<{ extensionId: string; stableKey?: string; activeTargets: number }>
|
||||||
}
|
}
|
||||||
const extension = data.extensions.find((item) => item.extensionId === extensionId)
|
const extension = data.extensions.find((item) => {
|
||||||
|
return item.extensionId === extensionId || item.stableKey === extensionId
|
||||||
|
})
|
||||||
if (!extension) {
|
if (!extension) {
|
||||||
return { connected: false, activeTargets: 0 }
|
return { connected: false, activeTargets: 0 }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user