-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
Implemented browser and browserPrivate #294
Changes from 1 commit
8b11819
7253ffc
5376f3d
cc68d5a
5828be0
4cf1a6d
5c6582a
53bb565
051edca
13a800c
27e4e3a
51fae87
cbc008b
b3212fb
aa21cad
f7b4c6d
238770d
009b28e
69b4bb5
e368f9b
1af76c2
a4867a4
b185554
6d9d524
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,10 +1,10 @@ | ||||||
const path = require('path'); | ||||||
const childProcess = require('child_process'); | ||||||
const {promises: fs, constants: fsConstants} = require('fs'); | ||||||
const isWsl = require('is-wsl'); | ||||||
const isDocker = require('is-docker'); | ||||||
const defineLazyProperty = require('define-lazy-prop'); | ||||||
const defaultBrowser = require('x-default-browser'); | ||||||
import path from 'path'; | ||||||
import childProcess from 'child_process'; | ||||||
import {promises as fs, constants as fsConstants} from 'fs'; | ||||||
import isWsl from 'is-wsl'; | ||||||
import isDocker from 'is-docker'; | ||||||
import defineLazyProperty from 'define-lazy-prop'; | ||||||
import defaultBrowser from 'default-browser'; | ||||||
|
||||||
// Path to included `xdg-open`. | ||||||
const localXdgOpenPath = path.join(__dirname, 'xdg-open'); | ||||||
|
@@ -119,20 +119,14 @@ const baseOpen = async options => { | |||||
} | ||||||
|
||||||
if (app === 'browser') { | ||||||
return defaultBrowser((error, browser) => { | ||||||
if (error) { | ||||||
throw error; | ||||||
const browser = await defaultBrowser(); | ||||||
const browserName = browser.name.toLowerCase(); | ||||||
return baseOpen({ | ||||||
...options, | ||||||
app: { | ||||||
name: open.apps[browserName], | ||||||
arguments: appArguments | ||||||
} | ||||||
|
||||||
const browserName = browser.commonName; | ||||||
|
||||||
baseOpen({ | ||||||
...options, | ||||||
app: { | ||||||
name: open.apps[browserName], | ||||||
arguments: appArguments | ||||||
} | ||||||
}); | ||||||
}); | ||||||
} | ||||||
|
||||||
|
@@ -144,20 +138,14 @@ const baseOpen = async options => { | |||||
edge: '--inPrivate' | ||||||
}; | ||||||
|
||||||
return defaultBrowser((error, browser) => { | ||||||
if (error) { | ||||||
throw error; | ||||||
const browser = await defaultBrowser(); | ||||||
const browserName = browser.name.toLowerCase(); | ||||||
return baseOpen({ | ||||||
...options, | ||||||
app: { | ||||||
name: open.apps[browserName], | ||||||
arguments: [...appArguments, flags[browserName]] | ||||||
} | ||||||
|
||||||
const browserName = browser.commonName; | ||||||
|
||||||
baseOpen({ | ||||||
...options, | ||||||
app: { | ||||||
name: open.apps[browserName], | ||||||
arguments: [...appArguments, flags[browserName]] | ||||||
} | ||||||
}); | ||||||
}); | ||||||
} | ||||||
|
||||||
|
@@ -379,4 +367,4 @@ defineLazyProperty(apps, 'browserPrivate', () => 'browserPrivate'); | |||||
open.apps = apps; | ||||||
open.openApp = openApp; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be named exports. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean something like this? export {apps};
export default open; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||||||
|
||||||
module.exports = open; | ||||||
export {open}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need to do some normalisation of the names.
browserName
will be different depending on the OS.