Find or download a version of Chrome for use with puppet-strings
Install puppet-strings-chrome by running:
yarn add puppet-strings-chrome
Find a locally installed stable version of Chrome or download it if none exists, and then launch it for use with puppet-strings
import { openChrome } from 'puppet-strings-chrome'
import { openTab } from 'puppet-strings'
async function run() {
const browser = await openChrome()
const tab = await openTab(browser, 'http:/example.com')
}
run()
openChrome()
takes the same options as
openBrowser()
openChrome()
uses findChrome()
to detect a locally installed
version of Chrome or Chromium, falling back to using
downloadChrome()
to download a usable version of Chromium.
Find the path to a locally installed stable version of Chromium or Google Chrome.
import { findChrome } from 'puppet-strings-chrome'
async function run() {
const chromePath = await findChrome()
console.log(chromePath)
}
run()
findChrome
returns null
if it can't find an executable.
Only Linux and OSX are supported.
findChrome
searches common paths such as:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
/usr/bin/chromium
/usr/bin/chromium-browser
/usr/bin/google-chrome
/usr/bin/google-chrome-stable
If no executables exist at any of these paths, findChrome
returns null
Download a version of Chromium that will work with puppet-strings.
import { downloadChrome } from 'puppet-strings-chrome'
async function run() {
const chromePath = await downloadChrome()
console.log(chromePath)
}
run()
downloadChrome()
downloads the
version of Chromium
compatible with the current version of Puppeteer. Downloads are cached in
~/.chromium
. If the version of Chromium is already downloaded, it will not be
downloaded again.