Skip to content
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

add method for printing found chrome path #255

Merged
merged 2 commits into from
Nov 9, 2021
Merged

Conversation

brendankenny
Copy link
Member

Using Lighthouse user flows, I find myself alternating between being fine with the version of Chrome shipped with puppeteer and needing the Canary installed on my machine, depending on what I'm doing, but it's awkward to set the path manually, and it's not portable (e.g. for sample code)

chrome-launcher is already set up to find Canary, so I've been wanting a way to be able to easily run something like

const browser = await puppeteer.launch({
  headless: false,
  executablePath: chromeLauncher.getChromePath(),
});

I don't see any non-ugly way of reaching into chrome-launcher to do this (someone correct me if I'm wrong), so this PR exposes a function to do this.

Also adds a bin option as I've also wanted it on the command line, e.g. CHROME_PATH="$(npm exec print-chrome-path)". Please suggest better approaches for that too, if there are any :)

@adamraine
Copy link
Member

This is better, but importing chrome-launcher everywhere in samples just to get the path to Canary doesn't seem ideal. Maybe we could add a getChromePath function to the FR API?

@@ -13,6 +13,9 @@
"type-check": "tsc --allowJs --checkJs --noEmit --target es2019 *.js",
"prepublishOnly": "npm run build && npm run test"
},
"bin": {
"print-chrome-path": "bin/print-chrome-path.js"
Copy link
Member

Choose a reason for hiding this comment

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

add this file plz :)

@@ -0,0 +1,16 @@
#!/usr/bin/env node
Copy link
Collaborator

@connorjclark connorjclark Nov 8, 2021

Choose a reason for hiding this comment

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

I assume this was chmod +x'd, although I don't know if there is a way to confirm that in GH ui.

related, benefits to using shebang vs just setting the bin script to node bin/print-chrome-path.js ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I assume this was chmod +x'd, although I don't know if there is a way to confirm that in GH ui

npm/yarn does the chmod on install

related, benefits to using shebang vs just setting the bin script to node bin/print-chrome-path.js ?

unlike script entries, bin entries are just filenames that are symlinked into node_modules/.bin, so need the shebang

Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL, thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants