-
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed75775
commit fb905a2
Showing
1 changed file
with
5 additions
and
8 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
> Open stuff like URLs, files, executables. Cross-platform. | ||
This is meant to be used in command-line tools and scripts, not in the browser. | ||
|
||
If need this for Electron, use [`shell.openItem()`](https://electronjs.org/docs/api/shell#shellopenitemfullpath) instead. | ||
|
||
Note: The original [`open` package](https://github.com/pwnall/node-open) was previously deprecated in favor of this package, and we got the name, so this package is now named `open` instead of `opn`. If you're upgrading from the original `open` package (`[email protected]` or lower), keep in mind that the API is different. | ||
|
@@ -15,14 +17,12 @@ Note: The original [`open` package](https://github.com/pwnall/node-open) was pre | |
- Includes the latest [`xdg-open` script](http://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=c55122295c2a480fa721a9614f0e2d42b2949c18) for Linux. | ||
- Supports WSL paths to Windows apps under `/mnt/*`. | ||
|
||
|
||
## Install | ||
|
||
``` | ||
$ npm install open | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
```js | ||
|
@@ -44,7 +44,6 @@ const open = require('open'); | |
})(); | ||
``` | ||
|
||
|
||
## API | ||
|
||
It uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms. | ||
|
@@ -67,7 +66,7 @@ Type: `object` | |
|
||
##### wait | ||
|
||
Type: `boolean`<br> | ||
Type: `boolean`\ | ||
Default: `false` | ||
|
||
Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app. | ||
|
@@ -78,7 +77,7 @@ On Windows, you have to explicitly specify an app for it to be able to wait. | |
|
||
##### background <sup>(macOS only)</sup> | ||
|
||
Type: `boolean`<br> | ||
Type: `boolean`\ | ||
Default: `false` | ||
|
||
Do not bring the app to the foreground. | ||
|
@@ -95,15 +94,14 @@ You may also pass in the app's full path. For example on WSL, this can be `/mnt/ | |
|
||
##### url | ||
|
||
Type: `boolean`<br> | ||
Type: `boolean`\ | ||
Default: `false` | ||
|
||
Uses `encodeURI` to encode the target before executing it.<br> | ||
We do not recommend using it on targets that are not URLs. | ||
|
||
Especially useful when dealing with the [double-quotes on Windows](#double-quotes-on-windows) caveat. | ||
|
||
|
||
## Caveats | ||
|
||
### Double-quotes on Windows | ||
|
@@ -129,7 +127,6 @@ The option that solved all of the problems was the second one, and for additiona | |
|
||
To make this caveat somewhat less impactful (at least for URLs), check out the [url option](#url). Double-quotes will be "preserved" when using it with an URL. | ||
|
||
|
||
## Related | ||
|
||
- [open-cli](https://github.com/sindresorhus/open-cli) - CLI for this module | ||
|