-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prep export of launcher as a standalone module (GoogleChrome/lighthou…
…se#2358) * prep to publish to npm * Use logger from lighthouse. * Add launcher README * Add notes for releasing chrome launcher * Launcher readme tweaks * docs (contributing): launcher rls tweak
- Loading branch information
Showing
5 changed files
with
1,015 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# folders | ||
.vscode/ | ||
test/ | ||
|
||
# dev files | ||
.appveyor.yml | ||
.editorconfig | ||
.eslintignore | ||
.eslintrc.js | ||
.travis.yml | ||
gulpfile.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Chrome Launcher | ||
|
||
Launch Google Chrome with ease from node. | ||
|
||
### Installing | ||
|
||
``` | ||
yarn add chrome-launcher | ||
``` | ||
|
||
or | ||
|
||
``` | ||
npm install chrome-launcher | ||
``` | ||
|
||
|
||
## API | ||
|
||
### `.launch([opts])` | ||
|
||
#### Launch options | ||
|
||
```ts | ||
{ | ||
// (optional) remote debugging port number to use. If provided port is already busy, launch() will reject | ||
// Default: an available port is autoselected | ||
port: number; | ||
|
||
// (optional) Additional flags to pass to Chrome, for example: ['--headless', '--disable-gpu'] | ||
// See all flags here: http://peter.sh/experiments/chromium-command-line-switches/ | ||
// Do note, many flags are set by default: https://github.com/GoogleChrome/lighthouse/blob/master/chrome-launcher/flags.ts | ||
chromeFlags: Array<string>; | ||
|
||
// (optional) Close the Chrome process on `Ctrl-C` | ||
// Default: true | ||
handleSIGINT: boolean; | ||
|
||
// (optional) Explicit path of intended Chrome binary | ||
// By default, any detected Chrome Canary or Chrome (stable) will be launched | ||
chromePath: string; | ||
|
||
// (optional) Chrome profile path to use | ||
// By default, a fresh Chrome profile will be created | ||
userDataDir: string; | ||
|
||
// (optional) Starting URL to open the browser with | ||
// Default: `about:blank` | ||
startingUrl: string; | ||
}; | ||
``` | ||
|
||
#### Launched chrome interface | ||
|
||
#### `.launch().then(chrome => ...` | ||
|
||
```ts | ||
// The remote debugging port exposed by the launched chrome | ||
chrome.port: number; | ||
|
||
// Method kill Chrome (and cleanup the profile folder) | ||
chrome.kill: () => Promise<{}>; | ||
|
||
// The process id | ||
chrome.pid: number; | ||
``` | ||
|
||
|
||
## Examples | ||
|
||
#### Launching chrome: | ||
|
||
```js | ||
const chromeLauncher = require('chrome-launcher'); | ||
|
||
chromeLauncher.launch({ | ||
startingUrl: 'https://google.com' | ||
}).then(chrome => { | ||
console.log(`Chrome debugging port running on ${chrome.port}`); | ||
}); | ||
``` | ||
|
||
|
||
#### Launching headless chrome: | ||
|
||
```js | ||
const chromeLauncher = require('chrome-launcher'); | ||
|
||
chromeLauncher.launch({ | ||
startingUrl: 'https://google.com', | ||
chromeFlags: ['--headless', '--disable-gpu'] | ||
}).then(chrome => { | ||
console.log(`Chrome debugging port running on ${chrome.port}`); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.