Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/domenic/opener
Opens stuff, like webpages and files and executables, cross-platform
https://github.com/domenic/opener
Last synced: 26 days ago
JSON representation
Opens stuff, like webpages and files and executables, cross-platform
- Host: GitHub
- URL: https://github.com/domenic/opener
- Owner: domenic
- License: other
- Created: 2012-08-06T10:40:30.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2022-08-17T15:12:47.000Z (about 2 years ago)
- Last Synced: 2024-08-30T16:15:55.870Z (2 months ago)
- Language: JavaScript
- Size: 43.9 KB
- Stars: 304
- Watchers: 7
- Forks: 28
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-tools - **opener** - 打开某个端口,固定文件 (脚手架以及工具包)
README
# It Opens Stuff
That is, in your desktop environment. This will make *actual windows pop up*, with stuff in them:
```bash
npm install opener -gopener http://google.com
opener ./my-file.txt
opener firefox
opener npm run lint
```Also if you want to use it programmatically you can do that too:
```js
var opener = require("opener");opener("http://google.com");
opener("./my-file.txt");
opener("firefox");
opener("npm run lint");
```Plus, it returns the child process created, so you can do things like let your script exit while the window stays open:
```js
var editor = opener("documentation.odt");
editor.unref();
// These other unrefs may be necessary if your OS's opener process
// exits before the process it started is complete.
editor.stdin.unref();
editor.stdout.unref();
editor.stderr.unref();
```## Use It for Good
Like opening the user's browser with a test harness in your package's test script:
```json
{
"scripts": {
"test": "opener ./test/runner.html"
},
"devDependencies": {
"opener": "*"
}
}
```## Why
Because Windows has `start`, Macs have `open`, and *nix has `xdg-open`. At least [according to some person on StackOverflow](http://stackoverflow.com/q/1480971/3191). And I like things that work on all three. Like Node.js. And Opener.