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 ability to open multiple urls at once #263

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
.idea
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ npm install chrome-launcher

// (optional) Starting URL to open the browser with
// Default: `about:blank`
startingUrl: string;
startingUrl: string | Array<string>;

// (optional) Logging level
// Default: 'silent'
Expand Down
7 changes: 4 additions & 3 deletions src/chrome-launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const instances = new Set<Launcher>();
type JSONLike =|{[property: string]: JSONLike}|readonly JSONLike[]|string|number|boolean|null;

export interface Options {
startingUrl?: string;
startingUrl?: string|Array<string>;
chromeFlags?: Array<string>;
prefs?: Record<string, JSONLike>;
port?: number;
Expand Down Expand Up @@ -111,7 +111,7 @@ function killAll(): Array<Error> {
class Launcher {
private tmpDirandPidFileReady = false;
private pidFile: string;
private startingUrl: string;
private startingUrl: string|Array<string>;
private outFile?: number;
private errFile?: number;
private chromePath?: string;
Expand Down Expand Up @@ -139,6 +139,7 @@ class Launcher {

// choose the first one (default)
this.startingUrl = defaults(this.opts.startingUrl, 'about:blank');
this.startingUrl = typeof this.startingUrl === 'string' ? [this.startingUrl] : this.startingUrl;
this.chromeFlags = defaults(this.opts.chromeFlags, []);
this.prefs = defaults(this.opts.prefs, {});
this.requestedPort = defaults(this.opts.port, 0);
Expand Down Expand Up @@ -178,7 +179,7 @@ class Launcher {
if (process.env.HEADLESS) flags.push('--headless');

flags.push(...this.chromeFlags);
flags.push(this.startingUrl);
flags.push(...this.startingUrl);

return flags;
}
Expand Down