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

Adds new config option iisexpress.openInBrowser to specify which browser to use with auto launch #100

Merged
merged 1 commit into from
Jul 10, 2020
Merged
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
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
"markdownDescription": "An option to disable or enable the browser from launching the site when IIS Express starts. By default this is **true**",
"default": true,
"type": "boolean"
},
"iisexpress.openInBrowser": {
"title": "Open in browser",
"markdownDescription": "Decide which browser to auto launch the site with when `iisexpress.autoLaunchBrowser` is set to **true**",
"markdownEnumDescriptions": ["Open in `Default Browser`", "Open in `Chrome`", "Open in `Edge`", "Open in `Firefox`", "Open in `Opera`"],
"enum": ["default", "chrome", "msedge", "firefox", "opera"],
"default": "default"
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions src/IISExpress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,19 @@ export class IIS {
}

public openWebsite(options?: settings.Isettings){

let browserConfig = vscode.workspace.getConfiguration().get<string>("iisexpress.openInBrowser", "default");
let browser:string = browserConfig.toLocaleLowerCase() === "default" ? "" : browserConfig;

if (options && options.url) {
// We have a starting URL set - but lets ensure we strip starting / if present
let startUrl = options.url.startsWith('/') ? options.url.substring(1) : options.url;

// Start browser with start url
process.exec(`start ${this._args.protocol}://localhost:${this._args.port}/${startUrl}`);
process.exec(`start ${browser} ${this._args.protocol}://localhost:${this._args.port}/${startUrl}`);
} else {
// Uses the 'start' command & url to open default browser
process.exec(`start ${this._args.protocol}://localhost:${this._args.port}`);
process.exec(`start ${browser} ${this._args.protocol}://localhost:${this._args.port}`);
}
}

Expand Down