lucaconte 7cc26e831d presentations | 6 роки тому | |
---|---|---|
.. | ||
cli.js | 6 роки тому | |
index.js | 6 роки тому | |
license | 6 роки тому | |
package.json | 6 роки тому | |
readme.md | 6 роки тому | |
xdg-open | 6 роки тому |
A better node-open. Opens stuff like websites, files, executables. Cross-platform.
node-open
issues$ npm install --save opn
var opn = require('opn');
opn('http://sindresorhus.com');
// opens that url in the default browser
opn('http://sindresorhus.com', 'firefox');
// you can also specify the app to open in
opn('unicorn.png');
// opens the image in the default image viewer
Uses the command open
on OS X, start
on Windows and xdg-open
on other platforms.
Required
Type: string
The thing you want to open. Can be a url, file, or executable.
Opens in the default app for the file type. Eg. urls opens in your default browser.
Type: string
Specify the app to open the target
with.
The app name is platform dependent. Don't hard code it in reusable modules.
Type: function
Executes when the opened app exits.
On Windows you have to explicitly specify an app for it to be able to wait.
You can also use it as a CLI app by installing it globally:
$ npm install --global opn
$ opn --help
Usage
$ opn <file|url> [app]
Example
$ opn http://sindresorhus.com
$ opn http://sindresorhus.com firefox
$ opn unicorn.png
MIT © Sindre Sorhus