Skip to content
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
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export type OpenAppOptions = {

export type AppName =
| 'chrome'
| 'brave'
| 'firefox'
| 'edge'
| 'browser'
Expand Down
14 changes: 14 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async function getWindowsDefaultBrowserFromWsl() {
// Map ProgId to browser IDs
const browserMap = {
ChromeHTML: 'com.google.chrome',
BraveHTML: 'com.brave.Browser',
MSEdgeHTM: 'com.microsoft.edge',
FirefoxURL: 'org.mozilla.firefox',
};
Expand Down Expand Up @@ -101,6 +102,7 @@ const baseOpen = async options => {
const ids = {
'com.google.chrome': 'chrome',
'google-chrome.desktop': 'chrome',
'com.brave.Browser': 'brave',
'org.mozilla.firefox': 'firefox',
'firefox.desktop': 'firefox',
'com.microsoft.msedge': 'edge',
Expand All @@ -112,6 +114,7 @@ const baseOpen = async options => {
// Incognito flags for each browser in `apps`.
const flags = {
chrome: '--incognito',
brave: '--incognito',
firefox: '--private-window',
edge: '--inPrivate',
};
Expand Down Expand Up @@ -328,6 +331,17 @@ defineLazyProperty(apps, 'chrome', () => detectPlatformBinary({
},
}));

defineLazyProperty(apps, 'brave', () => detectPlatformBinary({
darwin: 'brave browser',
win32: 'brave',
linux: ['brave-browser', 'brave'],
}, {
wsl: {
ia32: '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe',
x64: ['/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe', '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'],
},
}));

defineLazyProperty(apps, 'firefox', () => detectPlatformBinary({
darwin: 'firefox',
win32: 'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ await open('https://google.com', {
- [`chrome`](https://www.google.com/chrome) - Web browser
- [`firefox`](https://www.mozilla.org/firefox) - Web browser
- [`edge`](https://www.microsoft.com/edge) - Web browser
- [`brave`](https://brave.com/) - Web browser
- `browser` - Default web browser
- `browserPrivate` - Default web browser in incognito mode

`browser` and `browserPrivate` only supports `chrome`, `firefox`, and `edge`.
`browser` and `browserPrivate` only supports `chrome`, `firefox`, `edge`, and `brave`.

## Related

Expand Down
4 changes: 4 additions & 0 deletions test-it.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import open, {apps, openApp} from 'open';

await open('https://brave.com', {app: {name: apps.brave}});
await openApp(apps.brave, {arguments: ['https://brave.com', '--incognito'], newInstance: true});
4 changes: 4 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ test('open Chrome in incognito mode', async t => {
await t.notThrowsAsync(openApp(apps.chrome, {arguments: ['--incognito'], newInstance: true}));
});

test('open Brave in incognito mode', async t => {
await t.notThrowsAsync(openApp(apps.brave, {arguments: ['--incognito'], newInstance: true}));
});

test('open URL with default browser argument', async t => {
await t.notThrowsAsync(open('https://sindresorhus.com', {app: {name: apps.browser}}));
});
Expand Down