mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
# Conflicts: # jsowell-ui/.env.development # jsowell-ui/.env.staging # jsowell-ui/bin/build-sit.bat # jsowell-ui/bin/build.bat # jsowell-ui/src/api/adapayMember/adapayMember.js # jsowell-ui/src/api/pile/merchant.js # jsowell-ui/src/router/index.js # jsowell-ui/src/views/financial/financeDetail.vue # jsowell-ui/src/views/financial/merchant.vue # jsowell-ui/src/views/homeIndex/homeIndex.vue # jsowell-ui/src/views/login.vue # jsowell-ui/src/views/pile/basic/detail.vue # jsowell-ui/src/views/pile/station/components/SiteInfo.vue # jsowell-ui/src/views/pile/station/detail.vue # jsowell-ui/src/views/pile/station/orderReport.vue
55 lines
1.3 KiB
Markdown
55 lines
1.3 KiB
Markdown
# It Opens Stuff
|
|
|
|
That is, in your desktop environment. This will make *actual windows pop up*, with stuff in them:
|
|
|
|
```bash
|
|
npm install opener -g
|
|
|
|
opener 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.
|