-
-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
8b11819
Added browser and browserPrivate under open.apps
leslieyip02 7253ffc
Switched default browser library
leslieyip02 5376f3d
Updated docs
leslieyip02 cc68d5a
Fixed issue with __dirname
leslieyip02 5828be0
Fix: removed ava test from test script
leslieyip02 4cf1a6d
Fix the `app` argument with WSL (#295)
kazarmy 5c6582a
Removed unnecessary url import
leslieyip02 53bb565
Changed exports and specified supported browsers
leslieyip02 051edca
Fix `allowNonzeroExitCode` option (#296)
xirzec 13a800c
Meta tweaks
sindresorhus 27e4e3a
8.4.1
sindresorhus 51fae87
Fix support for Podman
sindresorhus cbc008b
8.4.2
sindresorhus b3212fb
Mapped browser IDs to supported browsers
leslieyip02 aa21cad
Added browser and browserPrivate under open.apps
leslieyip02 f7b4c6d
Switched default browser library
leslieyip02 238770d
Updated docs
leslieyip02 009b28e
Fixed issue with __dirname
leslieyip02 69b4bb5
Fix: removed ava test from test script
leslieyip02 e368f9b
Removed unnecessary url import
leslieyip02 1af76c2
Changed exports and specified supported browsers
leslieyip02 a4867a4
Mapped browser IDs to supported browsers
leslieyip02 b185554
Merge branch 'main' of https://github.com/leslieyip02/open
leslieyip02 6d9d524
Added documentation for apps export
leslieyip02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ npm install open | |
## Usage | ||
|
||
```js | ||
const open = require('open'); | ||
import open from 'open'; | ||
|
||
// Opens the image in the default image viewer and waits for the opened app to quit. | ||
await open('unicorn.png', {wait: true}); | ||
|
@@ -41,10 +41,13 @@ await open('https://sindresorhus.com', {app: {name: 'firefox'}}); | |
// Specify app arguments. | ||
await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}}); | ||
|
||
// Open an app | ||
// Opens the URL in the default browser in incognito mode. | ||
await open('https://sindresorhus.com', {app: {name: open.apps.browserPrivate}}); | ||
|
||
// Open an app. | ||
await open.openApp('xcode'); | ||
|
||
// Open an app with arguments | ||
// Open an app with arguments. | ||
await open.openApp(open.apps.chrome, {arguments: ['--incognito']}); | ||
``` | ||
|
||
|
@@ -116,25 +119,40 @@ Allow the opened app to exit with nonzero exit code when the `wait` option is `t | |
|
||
We do not recommend setting this option. The convention for success is exit code zero. | ||
|
||
### open.apps | ||
### open.apps / apps | ||
|
||
An object containing auto-detected binary names for common apps. Useful to work around [cross-platform differences](#app). | ||
|
||
```js | ||
const open = require('open'); | ||
// Using default export. | ||
import open from 'open'; | ||
|
||
await open('https://google.com', { | ||
app: { | ||
name: open.apps.chrome | ||
} | ||
}); | ||
|
||
// Using named export. | ||
import open, {apps} from 'open'; | ||
|
||
await open('https://firefox.com', { | ||
app: { | ||
name: apps.browserPrivate | ||
} | ||
}); | ||
``` | ||
`browser` and `browserPrivate` can also be used to access the user's default browser through [`default-browser`](https://github.com/sindresorhus/default-browser). | ||
|
||
#### Supported apps | ||
|
||
- [`chrome`](https://www.google.com/chrome) - Web browser | ||
- [`firefox`](https://www.mozilla.org/firefox) - Web browser | ||
- [`edge`](https://www.microsoft.com/edge) - Web browser | ||
- `browser` - Default web browser | ||
- `browserPrivate` - Default web browser in incognito mode | ||
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. This needs to document which browsers it supports. |
||
|
||
`browser` and `browserPrivate` only supports `chrome`, `firefox` and `edge`. | ||
|
||
### open.openApp(name, options?) | ||
|
||
|
@@ -169,15 +187,3 @@ These arguments are app dependent. Check the app's documentation for what argume | |
|
||
- [open-cli](https://github.com/sindresorhus/open-cli) - CLI for this module | ||
- [open-editor](https://github.com/sindresorhus/open-editor) - Open files in your editor at a specific line and column | ||
|
||
--- | ||
|
||
<div align="center"> | ||
<b> | ||
<a href="https://tidelift.com/subscription/pkg/npm-opn?utm_source=npm-opn&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
</b> | ||
<br> | ||
<sub> | ||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
</sub> | ||
</div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These should be named exports.
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 mean something like this?
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.
Yes