Skip to content

Commit

Permalink
Add ability to open multiple urls at once
Browse files Browse the repository at this point in the history
  • Loading branch information
XoddX authored and Esteban Pasquier committed Apr 5, 2022
1 parent 279577f commit 028ea38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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 @@ async function killAll(): Promise<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 @@ -176,7 +177,7 @@ class Launcher {
}

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

return flags;
}
Expand Down

0 comments on commit 028ea38

Please sign in to comment.