mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-10 21:01:41 +00:00
update
This commit is contained in:
96
node_modules/opn/index.js
generated
vendored
Normal file
96
node_modules/opn/index.js
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const isWsl = require('is-wsl');
|
||||
|
||||
module.exports = (target, opts) => {
|
||||
if (typeof target !== 'string') {
|
||||
return Promise.reject(new Error('Expected a `target`'));
|
||||
}
|
||||
|
||||
opts = Object.assign({wait: true}, opts);
|
||||
|
||||
let cmd;
|
||||
let appArgs = [];
|
||||
let args = [];
|
||||
const cpOpts = {};
|
||||
|
||||
if (Array.isArray(opts.app)) {
|
||||
appArgs = opts.app.slice(1);
|
||||
opts.app = opts.app[0];
|
||||
}
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
cmd = 'open';
|
||||
|
||||
if (opts.wait) {
|
||||
args.push('-W');
|
||||
}
|
||||
|
||||
if (opts.app) {
|
||||
args.push('-a', opts.app);
|
||||
}
|
||||
} else if (process.platform === 'win32' || isWsl) {
|
||||
cmd = 'cmd' + (isWsl ? '.exe' : '');
|
||||
args.push('/c', 'start', '""', '/b');
|
||||
target = target.replace(/&/g, '^&');
|
||||
|
||||
if (opts.wait) {
|
||||
args.push('/wait');
|
||||
}
|
||||
|
||||
if (opts.app) {
|
||||
args.push(opts.app);
|
||||
}
|
||||
|
||||
if (appArgs.length > 0) {
|
||||
args = args.concat(appArgs);
|
||||
}
|
||||
} else {
|
||||
if (opts.app) {
|
||||
cmd = opts.app;
|
||||
} else {
|
||||
cmd = process.platform === 'android' ? 'xdg-open' : path.join(__dirname, 'xdg-open');
|
||||
}
|
||||
|
||||
if (appArgs.length > 0) {
|
||||
args = args.concat(appArgs);
|
||||
}
|
||||
|
||||
if (!opts.wait) {
|
||||
// `xdg-open` will block the process unless
|
||||
// stdio is ignored and it's detached from the parent
|
||||
// even if it's unref'd
|
||||
cpOpts.stdio = 'ignore';
|
||||
cpOpts.detached = true;
|
||||
}
|
||||
}
|
||||
|
||||
args.push(target);
|
||||
|
||||
if (process.platform === 'darwin' && appArgs.length > 0) {
|
||||
args.push('--args');
|
||||
args = args.concat(appArgs);
|
||||
}
|
||||
|
||||
const cp = childProcess.spawn(cmd, args, cpOpts);
|
||||
|
||||
if (opts.wait) {
|
||||
return new Promise((resolve, reject) => {
|
||||
cp.once('error', reject);
|
||||
|
||||
cp.once('close', code => {
|
||||
if (code > 0) {
|
||||
reject(new Error('Exited with code ' + code));
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(cp);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
cp.unref();
|
||||
|
||||
return Promise.resolve(cp);
|
||||
};
|
9
node_modules/opn/license
generated
vendored
Normal file
9
node_modules/opn/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
91
node_modules/opn/package.json
generated
vendored
Normal file
91
node_modules/opn/package.json
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"opn@5.3.0",
|
||||
"/Users/tatiana/selfdefined"
|
||||
]
|
||||
],
|
||||
"_from": "opn@5.3.0",
|
||||
"_id": "opn@5.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-bYJHo/LOmoTd+pfiYhfZDnf9zekVJrY+cnS2a5F2x+w5ppvTqObojTP7WiFG+kVZs9Inw+qQ/lw7TroWwhdd2g==",
|
||||
"_location": "/opn",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "opn@5.3.0",
|
||||
"name": "opn",
|
||||
"escapedName": "opn",
|
||||
"rawSpec": "5.3.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "5.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/browser-sync"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/opn/-/opn-5.3.0.tgz",
|
||||
"_spec": "5.3.0",
|
||||
"_where": "/Users/tatiana/selfdefined",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/opn/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-wsl": "^1.1.0"
|
||||
},
|
||||
"description": "A better node-open. Opens stuff like websites, files, executables. Cross-platform.",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"xdg-open"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/opn#readme",
|
||||
"keywords": [
|
||||
"app",
|
||||
"open",
|
||||
"opn",
|
||||
"opener",
|
||||
"opens",
|
||||
"launch",
|
||||
"start",
|
||||
"xdg-open",
|
||||
"xdg",
|
||||
"default",
|
||||
"cmd",
|
||||
"browser",
|
||||
"editor",
|
||||
"executable",
|
||||
"exe",
|
||||
"url",
|
||||
"urls",
|
||||
"arguments",
|
||||
"args",
|
||||
"spawn",
|
||||
"exec",
|
||||
"child",
|
||||
"process",
|
||||
"website",
|
||||
"file"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "opn",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/opn.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "5.3.0"
|
||||
}
|
88
node_modules/opn/readme.md
generated
vendored
Normal file
88
node_modules/opn/readme.md
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
# opn
|
||||
|
||||
> A better [node-open](https://github.com/pwnall/node-open). Opens stuff like websites, files, executables. Cross-platform.
|
||||
|
||||
|
||||
#### Why?
|
||||
|
||||
- Actively maintained
|
||||
- Supports app arguments
|
||||
- Safer as it uses `spawn` instead of `exec`
|
||||
- Fixes most of the open `node-open` issues
|
||||
- Includes the latest [`xdg-open` script](http://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=c55122295c2a480fa721a9614f0e2d42b2949c18) for Linux
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install opn
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const opn = require('opn');
|
||||
|
||||
// Opens the image in the default image viewer
|
||||
opn('unicorn.png').then(() => {
|
||||
// image viewer closed
|
||||
});
|
||||
|
||||
// Opens the url in the default browser
|
||||
opn('http://sindresorhus.com');
|
||||
|
||||
// Specify the app to open in
|
||||
opn('http://sindresorhus.com', {app: 'firefox'});
|
||||
|
||||
// Specify app arguments
|
||||
opn('http://sindresorhus.com', {app: ['google chrome', '--incognito']});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
|
||||
|
||||
### opn(target, [options])
|
||||
|
||||
Returns a promise for the [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
||||
|
||||
#### target
|
||||
|
||||
Type: `string`
|
||||
|
||||
The thing you want to open. Can be a URL, file, or executable.
|
||||
|
||||
Opens in the default app for the file type. For example, URLs opens in your default browser.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### wait
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
|
||||
|
||||
On Windows you have to explicitly specify an app for it to be able to wait.
|
||||
|
||||
##### app
|
||||
|
||||
Type: `string` `Array`
|
||||
|
||||
Specify the app to open the `target` with, or an array with the app and app arguments.
|
||||
|
||||
The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [opn-cli](https://github.com/sindresorhus/opn-cli) - CLI for this module
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
1025
node_modules/opn/xdg-open
generated
vendored
Executable file
1025
node_modules/opn/xdg-open
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user