Skip to content

Commit 028ea38

Browse files
XoddXEsteban Pasquier
authored and
Esteban Pasquier
committed
Add ability to open multiple urls at once
1 parent 279577f commit 028ea38

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
dist
3+
.idea

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ npm install chrome-launcher
6262

6363
// (optional) Starting URL to open the browser with
6464
// Default: `about:blank`
65-
startingUrl: string;
65+
startingUrl: string | Array<string>;
6666

6767
// (optional) Logging level
6868
// Default: 'silent'

Diff for: src/chrome-launcher.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const instances = new Set<Launcher>();
2929
type JSONLike =|{[property: string]: JSONLike}|readonly JSONLike[]|string|number|boolean|null;
3030

3131
export interface Options {
32-
startingUrl?: string;
32+
startingUrl?: string|Array<string>;
3333
chromeFlags?: Array<string>;
3434
prefs?: Record<string, JSONLike>;
3535
port?: number;
@@ -111,7 +111,7 @@ async function killAll(): Promise<Array<Error>> {
111111
class Launcher {
112112
private tmpDirandPidFileReady = false;
113113
private pidFile: string;
114-
private startingUrl: string;
114+
private startingUrl: string|Array<string>;
115115
private outFile?: number;
116116
private errFile?: number;
117117
private chromePath?: string;
@@ -139,6 +139,7 @@ class Launcher {
139139

140140
// choose the first one (default)
141141
this.startingUrl = defaults(this.opts.startingUrl, 'about:blank');
142+
this.startingUrl = typeof this.startingUrl === 'string' ? [this.startingUrl] : this.startingUrl;
142143
this.chromeFlags = defaults(this.opts.chromeFlags, []);
143144
this.prefs = defaults(this.opts.prefs, {});
144145
this.requestedPort = defaults(this.opts.port, 0);
@@ -176,7 +177,7 @@ class Launcher {
176177
}
177178

178179
flags.push(...this.chromeFlags);
179-
flags.push(this.startingUrl);
180+
flags.push(...this.startingUrl);
180181

181182
return flags;
182183
}

0 commit comments

Comments
 (0)