Skip to content

chore: don't fail when browser is already installed #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/tools/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,22 @@ const install = defineTool({
const child = fork(cli, ['install', channel], {
stdio: 'pipe',
});
const output: string[] = [];
child.stdout?.on('data', data => output.push(data.toString()));
child.stderr?.on('data', data => output.push(data.toString()));
await new Promise<void>((resolve, reject) => {
const chunks: string[] = [];
child.stdout?.on('data', data => chunks.push(data.toString()));
child.stderr?.on('data', data => chunks.push(data.toString()));
const code = await new Promise<string>((resolve, reject) => {
child.on('close', code => {
const output = chunks.join('');
if (code === 0)
resolve();
resolve(`// Browser ${channel} installed`);
else if (output.includes('already installed'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's going to break over time, especially if we don't have a test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What'd you recommend instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make installing chrome idempotent upstream?

resolve(`// Browser ${channel} is already installed`);
else
reject(new Error(`Failed to install browser: ${output.join('')}`));
reject(new Error(`Failed to install browser: ${output}`));
});
});
return {
code: [`// Browser ${channel} installed`],
code: [code],
captureSnapshot: false,
waitForNetwork: false,
};
Expand Down