Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
22
node_modules/default-gateway/LICENSE
generated
vendored
Normal file
22
node_modules/default-gateway/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
Copyright (c) silverwind
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
51
node_modules/default-gateway/README.md
generated
vendored
Normal file
51
node_modules/default-gateway/README.md
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
# default-gateway
|
||||
[](https://www.npmjs.org/package/default-gateway) [](https://www.npmjs.org/package/default-gateway)
|
||||
|
||||
Obtains the machine's default gateway through `exec` calls to OS routing interfaces.
|
||||
|
||||
- On Linux and Android, the `ip` command must be available (usually provided by the `iproute2` package).
|
||||
- On Windows, `wmic` must be available.
|
||||
- On IBM i, the `db2util` command must be available (provided by the `db2util` package).
|
||||
- On Unix (and macOS), the `netstat` command must be available.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ npm i default-gateway
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const defaultGateway = require('default-gateway');
|
||||
|
||||
const {gateway, interface} = await defaultGateway.v4();
|
||||
// gateway = '1.2.3.4', interface = 'en1'
|
||||
|
||||
const {gateway, interface} = await defaultGateway.v6();
|
||||
// gateway = '2001:db8::1', interface = 'en2'
|
||||
|
||||
const {gateway, interface} = defaultGateway.v4.sync();
|
||||
// gateway = '1.2.3.4', interface = 'en1'
|
||||
|
||||
const {gateway, interface} = defaultGateway.v6.sync();
|
||||
// gateway = '2001:db8::1', interface = 'en2'
|
||||
```
|
||||
|
||||
## API
|
||||
### defaultGateway.v4()
|
||||
### defaultGateway.v6()
|
||||
### defaultGateway.v4.sync()
|
||||
### defaultGateway.v6.sync()
|
||||
|
||||
Returns: `result` *Object*
|
||||
- `gateway`: The IP address of the default gateway.
|
||||
- `interface`: The name of the interface. On Windows, this is the network adapter name.
|
||||
|
||||
The `.v{4,6}()` methods return a Promise while the `.v{4,6}.sync()` variants will return the result synchronously.
|
||||
|
||||
The `gateway` property will always be defined on success, while `interface` can be `null` if it cannot be determined. All methods reject/throw on unexpected conditions.
|
||||
|
||||
## License
|
||||
|
||||
© [silverwind](https://github.com/silverwind), distributed under BSD licence
|
43
node_modules/default-gateway/android.js
generated
vendored
Normal file
43
node_modules/default-gateway/android.js
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
"use strict";
|
||||
|
||||
const {isIP} = require("net");
|
||||
const execa = require("execa");
|
||||
|
||||
const args = {
|
||||
v4: ["-4", "r"],
|
||||
v6: ["-6", "r"],
|
||||
};
|
||||
|
||||
const parse = stdout => {
|
||||
let result;
|
||||
|
||||
(stdout || "").trim().split("\n").some(line => {
|
||||
const [_, gateway, iface] = /default via (.+?) dev (.+?)( |$)/.exec(line) || [];
|
||||
if (gateway && isIP(gateway)) {
|
||||
result = {gateway, interface: (iface ? iface : null)};
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
throw new Error("Unable to determine default gateway");
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const promise = async family => {
|
||||
const {stdout} = await execa("ip", args[family]);
|
||||
return parse(stdout, family);
|
||||
};
|
||||
|
||||
const sync = family => {
|
||||
const {stdout} = execa.sync("ip", args[family]);
|
||||
return parse(stdout);
|
||||
};
|
||||
|
||||
module.exports.v4 = () => promise("v4");
|
||||
module.exports.v6 = () => promise("v6");
|
||||
|
||||
module.exports.v4.sync = () => sync("v4");
|
||||
module.exports.v6.sync = () => sync("v6");
|
52
node_modules/default-gateway/darwin.js
generated
vendored
Normal file
52
node_modules/default-gateway/darwin.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
"use strict";
|
||||
|
||||
const {isIP} = require("net");
|
||||
const {release} = require("os");
|
||||
const execa = require("execa");
|
||||
const dests = new Set(["default", "0.0.0.0", "0.0.0.0/0", "::", "::/0"]);
|
||||
|
||||
const args = {
|
||||
v4: ["-rn", "-f", "inet"],
|
||||
v6: ["-rn", "-f", "inet6"],
|
||||
};
|
||||
|
||||
// The IPv4 gateway is in column 3 in Darwin 19 (macOS 10.15 Catalina) and higher,
|
||||
// previously it was in column 5
|
||||
const v4IfaceColumn = parseInt(release()) >= 19 ? 3 : 5;
|
||||
|
||||
const parse = (stdout, family) => {
|
||||
let result;
|
||||
|
||||
(stdout || "").trim().split("\n").some(line => {
|
||||
const results = line.split(/ +/) || [];
|
||||
const target = results[0];
|
||||
const gateway = results[1];
|
||||
const iface = results[family === "v4" ? v4IfaceColumn : 3];
|
||||
if (dests.has(target) && gateway && isIP(gateway)) {
|
||||
result = {gateway, interface: (iface ? iface : null)};
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
throw new Error("Unable to determine default gateway");
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const promise = async family => {
|
||||
const {stdout} = await execa("netstat", args[family]);
|
||||
return parse(stdout, family);
|
||||
};
|
||||
|
||||
const sync = family => {
|
||||
const {stdout} = execa.sync("netstat", args[family]);
|
||||
return parse(stdout, family);
|
||||
};
|
||||
|
||||
module.exports.v4 = () => promise("v4");
|
||||
module.exports.v6 = () => promise("v6");
|
||||
|
||||
module.exports.v4.sync = () => sync("v4");
|
||||
module.exports.v6.sync = () => sync("v6");
|
44
node_modules/default-gateway/freebsd.js
generated
vendored
Normal file
44
node_modules/default-gateway/freebsd.js
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
"use strict";
|
||||
|
||||
const {isIP} = require("net");
|
||||
const execa = require("execa");
|
||||
const dests = new Set(["default", "0.0.0.0", "0.0.0.0/0", "::", "::/0"]);
|
||||
|
||||
const args = {
|
||||
v4: ["-rn", "-f", "inet"],
|
||||
v6: ["-rn", "-f", "inet6"],
|
||||
};
|
||||
|
||||
const parse = stdout => {
|
||||
let result;
|
||||
|
||||
(stdout || "").trim().split("\n").some(line => {
|
||||
const [target, gateway, _, iface] = line.split(/ +/) || [];
|
||||
if (dests.has(target) && gateway && isIP(gateway)) {
|
||||
result = {gateway, interface: (iface ? iface : null)};
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
throw new Error("Unable to determine default gateway");
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const promise = async family => {
|
||||
const {stdout} = await execa("netstat", args[family]);
|
||||
return parse(stdout);
|
||||
};
|
||||
|
||||
const sync = family => {
|
||||
const {stdout} = execa.sync("netstat", args[family]);
|
||||
return parse(stdout);
|
||||
};
|
||||
|
||||
module.exports.v4 = () => promise("v4");
|
||||
module.exports.v6 = () => promise("v6");
|
||||
|
||||
module.exports.v4.sync = () => sync("v4");
|
||||
module.exports.v6.sync = () => sync("v6");
|
36
node_modules/default-gateway/ibmi.js
generated
vendored
Normal file
36
node_modules/default-gateway/ibmi.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
"use strict";
|
||||
|
||||
const execa = require("execa");
|
||||
|
||||
const db2util = "/QOpenSys/pkgs/bin/db2util";
|
||||
const sql = "select NEXT_HOP, LOCAL_BINDING_INTERFACE from QSYS2.NETSTAT_ROUTE_INFO where ROUTE_TYPE='DFTROUTE' and NEXT_HOP!='*DIRECT' and CONNECTION_TYPE=?";
|
||||
|
||||
const parse = stdout => {
|
||||
let result;
|
||||
try {
|
||||
const resultObj = JSON.parse(stdout);
|
||||
const gateway = resultObj.records[0].NEXT_HOP;
|
||||
const iface = resultObj.records[0].LOCAL_BINDING_INTERFACE;
|
||||
result = {gateway, iface};
|
||||
} catch {}
|
||||
if (!result) {
|
||||
throw new Error("Unable to determine default gateway");
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const promise = async family => {
|
||||
const {stdout} = await execa(db2util, [sql, "-p", family, "-o", "json"]);
|
||||
return parse(stdout);
|
||||
};
|
||||
|
||||
const sync = family => {
|
||||
const {stdout} = execa.sync(db2util, [sql, "-p", family, "-o", "json"]);
|
||||
return parse(stdout);
|
||||
};
|
||||
|
||||
module.exports.v4 = () => promise("IPV4");
|
||||
module.exports.v6 = () => promise("IPV6");
|
||||
|
||||
module.exports.v4.sync = () => sync("IPV4");
|
||||
module.exports.v6.sync = () => sync("IPV6");
|
35
node_modules/default-gateway/index.js
generated
vendored
Normal file
35
node_modules/default-gateway/index.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
"use strict";
|
||||
|
||||
const {platform, type} = require("os");
|
||||
|
||||
const supportedPlatforms = new Set([
|
||||
"aix",
|
||||
"android",
|
||||
"darwin",
|
||||
"freebsd",
|
||||
"linux",
|
||||
"openbsd",
|
||||
"sunos",
|
||||
"win32"
|
||||
]);
|
||||
|
||||
const plat = platform();
|
||||
|
||||
if (supportedPlatforms.has(plat)) {
|
||||
let file = plat;
|
||||
if (plat === "aix") {
|
||||
file = type() === "OS400" ? "ibmi" : "sunos"; // AIX `netstat` output is compatible with Solaris
|
||||
}
|
||||
|
||||
const m = require(`./${file}.js`);
|
||||
module.exports.v4 = () => m.v4();
|
||||
module.exports.v6 = () => m.v6();
|
||||
module.exports.v4.sync = () => m.v4.sync();
|
||||
module.exports.v6.sync = () => m.v6.sync();
|
||||
} else {
|
||||
const err = new Error(`Unsupported Platform: ${plat}`);
|
||||
module.exports.v4 = () => Promise.reject(err);
|
||||
module.exports.v6 = () => Promise.reject(err);
|
||||
module.exports.v4.sync = () => { throw err; };
|
||||
module.exports.v6.sync = () => { throw err; };
|
||||
}
|
57
node_modules/default-gateway/linux.js
generated
vendored
Normal file
57
node_modules/default-gateway/linux.js
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
"use strict";
|
||||
|
||||
const {isIP} = require("net");
|
||||
const {networkInterfaces} = require("os");
|
||||
const execa = require("execa");
|
||||
|
||||
const args = {
|
||||
v4: ["-4", "r"],
|
||||
v6: ["-6", "r"],
|
||||
};
|
||||
|
||||
const parse = (stdout, family) => {
|
||||
let result;
|
||||
|
||||
(stdout || "").trim().split("\n").some(line => {
|
||||
const results = /default( via .+?)?( dev .+?)( |$)/.exec(line) || [];
|
||||
const gateway = (results[1] || "").substring(5);
|
||||
const iface = (results[2] || "").substring(5);
|
||||
if (gateway && isIP(gateway)) { // default via 1.2.3.4 dev en0
|
||||
result = {gateway, interface: (iface ? iface : null)};
|
||||
return true;
|
||||
} else if (iface && !gateway) { // default via dev en0
|
||||
const interfaces = networkInterfaces();
|
||||
const addresses = interfaces[iface];
|
||||
if (!addresses || !addresses.length) return;
|
||||
|
||||
addresses.some(addr => {
|
||||
if (addr.family.substring(2) === family && isIP(addr.address)) {
|
||||
result = {gateway: addr.address, interface: (iface ? iface : null)};
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
throw new Error("Unable to determine default gateway");
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const promise = async family => {
|
||||
const {stdout} = await execa("ip", args[family]);
|
||||
return parse(stdout, family);
|
||||
};
|
||||
|
||||
const sync = family => {
|
||||
const {stdout} = execa.sync("ip", args[family]);
|
||||
return parse(stdout, family);
|
||||
};
|
||||
|
||||
module.exports.v4 = () => promise("v4");
|
||||
module.exports.v6 = () => promise("v6");
|
||||
|
||||
module.exports.v4.sync = () => sync("v4");
|
||||
module.exports.v6.sync = () => sync("v6");
|
268
node_modules/default-gateway/node_modules/execa/index.js
generated
vendored
Normal file
268
node_modules/default-gateway/node_modules/execa/index.js
generated
vendored
Normal file
|
@ -0,0 +1,268 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const crossSpawn = require('cross-spawn');
|
||||
const stripFinalNewline = require('strip-final-newline');
|
||||
const npmRunPath = require('npm-run-path');
|
||||
const onetime = require('onetime');
|
||||
const makeError = require('./lib/error');
|
||||
const normalizeStdio = require('./lib/stdio');
|
||||
const {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} = require('./lib/kill');
|
||||
const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = require('./lib/stream');
|
||||
const {mergePromise, getSpawnedPromise} = require('./lib/promise');
|
||||
const {joinCommand, parseCommand, getEscapedCommand} = require('./lib/command');
|
||||
|
||||
const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
|
||||
|
||||
const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
|
||||
const env = extendEnv ? {...process.env, ...envOption} : envOption;
|
||||
|
||||
if (preferLocal) {
|
||||
return npmRunPath.env({env, cwd: localDir, execPath});
|
||||
}
|
||||
|
||||
return env;
|
||||
};
|
||||
|
||||
const handleArguments = (file, args, options = {}) => {
|
||||
const parsed = crossSpawn._parse(file, args, options);
|
||||
file = parsed.command;
|
||||
args = parsed.args;
|
||||
options = parsed.options;
|
||||
|
||||
options = {
|
||||
maxBuffer: DEFAULT_MAX_BUFFER,
|
||||
buffer: true,
|
||||
stripFinalNewline: true,
|
||||
extendEnv: true,
|
||||
preferLocal: false,
|
||||
localDir: options.cwd || process.cwd(),
|
||||
execPath: process.execPath,
|
||||
encoding: 'utf8',
|
||||
reject: true,
|
||||
cleanup: true,
|
||||
all: false,
|
||||
windowsHide: true,
|
||||
...options
|
||||
};
|
||||
|
||||
options.env = getEnv(options);
|
||||
|
||||
options.stdio = normalizeStdio(options);
|
||||
|
||||
if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
|
||||
// #116
|
||||
args.unshift('/q');
|
||||
}
|
||||
|
||||
return {file, args, options, parsed};
|
||||
};
|
||||
|
||||
const handleOutput = (options, value, error) => {
|
||||
if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
|
||||
// When `execa.sync()` errors, we normalize it to '' to mimic `execa()`
|
||||
return error === undefined ? undefined : '';
|
||||
}
|
||||
|
||||
if (options.stripFinalNewline) {
|
||||
return stripFinalNewline(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
const execa = (file, args, options) => {
|
||||
const parsed = handleArguments(file, args, options);
|
||||
const command = joinCommand(file, args);
|
||||
const escapedCommand = getEscapedCommand(file, args);
|
||||
|
||||
validateTimeout(parsed.options);
|
||||
|
||||
let spawned;
|
||||
try {
|
||||
spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
|
||||
} catch (error) {
|
||||
// Ensure the returned error is always both a promise and a child process
|
||||
const dummySpawned = new childProcess.ChildProcess();
|
||||
const errorPromise = Promise.reject(makeError({
|
||||
error,
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
all: '',
|
||||
command,
|
||||
escapedCommand,
|
||||
parsed,
|
||||
timedOut: false,
|
||||
isCanceled: false,
|
||||
killed: false
|
||||
}));
|
||||
return mergePromise(dummySpawned, errorPromise);
|
||||
}
|
||||
|
||||
const spawnedPromise = getSpawnedPromise(spawned);
|
||||
const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
|
||||
const processDone = setExitHandler(spawned, parsed.options, timedPromise);
|
||||
|
||||
const context = {isCanceled: false};
|
||||
|
||||
spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
|
||||
spawned.cancel = spawnedCancel.bind(null, spawned, context);
|
||||
|
||||
const handlePromise = async () => {
|
||||
const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
|
||||
const stdout = handleOutput(parsed.options, stdoutResult);
|
||||
const stderr = handleOutput(parsed.options, stderrResult);
|
||||
const all = handleOutput(parsed.options, allResult);
|
||||
|
||||
if (error || exitCode !== 0 || signal !== null) {
|
||||
const returnedError = makeError({
|
||||
error,
|
||||
exitCode,
|
||||
signal,
|
||||
stdout,
|
||||
stderr,
|
||||
all,
|
||||
command,
|
||||
escapedCommand,
|
||||
parsed,
|
||||
timedOut,
|
||||
isCanceled: context.isCanceled,
|
||||
killed: spawned.killed
|
||||
});
|
||||
|
||||
if (!parsed.options.reject) {
|
||||
return returnedError;
|
||||
}
|
||||
|
||||
throw returnedError;
|
||||
}
|
||||
|
||||
return {
|
||||
command,
|
||||
escapedCommand,
|
||||
exitCode: 0,
|
||||
stdout,
|
||||
stderr,
|
||||
all,
|
||||
failed: false,
|
||||
timedOut: false,
|
||||
isCanceled: false,
|
||||
killed: false
|
||||
};
|
||||
};
|
||||
|
||||
const handlePromiseOnce = onetime(handlePromise);
|
||||
|
||||
handleInput(spawned, parsed.options.input);
|
||||
|
||||
spawned.all = makeAllStream(spawned, parsed.options);
|
||||
|
||||
return mergePromise(spawned, handlePromiseOnce);
|
||||
};
|
||||
|
||||
module.exports = execa;
|
||||
|
||||
module.exports.sync = (file, args, options) => {
|
||||
const parsed = handleArguments(file, args, options);
|
||||
const command = joinCommand(file, args);
|
||||
const escapedCommand = getEscapedCommand(file, args);
|
||||
|
||||
validateInputSync(parsed.options);
|
||||
|
||||
let result;
|
||||
try {
|
||||
result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options);
|
||||
} catch (error) {
|
||||
throw makeError({
|
||||
error,
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
all: '',
|
||||
command,
|
||||
escapedCommand,
|
||||
parsed,
|
||||
timedOut: false,
|
||||
isCanceled: false,
|
||||
killed: false
|
||||
});
|
||||
}
|
||||
|
||||
const stdout = handleOutput(parsed.options, result.stdout, result.error);
|
||||
const stderr = handleOutput(parsed.options, result.stderr, result.error);
|
||||
|
||||
if (result.error || result.status !== 0 || result.signal !== null) {
|
||||
const error = makeError({
|
||||
stdout,
|
||||
stderr,
|
||||
error: result.error,
|
||||
signal: result.signal,
|
||||
exitCode: result.status,
|
||||
command,
|
||||
escapedCommand,
|
||||
parsed,
|
||||
timedOut: result.error && result.error.code === 'ETIMEDOUT',
|
||||
isCanceled: false,
|
||||
killed: result.signal !== null
|
||||
});
|
||||
|
||||
if (!parsed.options.reject) {
|
||||
return error;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
return {
|
||||
command,
|
||||
escapedCommand,
|
||||
exitCode: 0,
|
||||
stdout,
|
||||
stderr,
|
||||
failed: false,
|
||||
timedOut: false,
|
||||
isCanceled: false,
|
||||
killed: false
|
||||
};
|
||||
};
|
||||
|
||||
module.exports.command = (command, options) => {
|
||||
const [file, ...args] = parseCommand(command);
|
||||
return execa(file, args, options);
|
||||
};
|
||||
|
||||
module.exports.commandSync = (command, options) => {
|
||||
const [file, ...args] = parseCommand(command);
|
||||
return execa.sync(file, args, options);
|
||||
};
|
||||
|
||||
module.exports.node = (scriptPath, args, options = {}) => {
|
||||
if (args && !Array.isArray(args) && typeof args === 'object') {
|
||||
options = args;
|
||||
args = [];
|
||||
}
|
||||
|
||||
const stdio = normalizeStdio.node(options);
|
||||
const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));
|
||||
|
||||
const {
|
||||
nodePath = process.execPath,
|
||||
nodeOptions = defaultExecArgv
|
||||
} = options;
|
||||
|
||||
return execa(
|
||||
nodePath,
|
||||
[
|
||||
...nodeOptions,
|
||||
scriptPath,
|
||||
...(Array.isArray(args) ? args : [])
|
||||
],
|
||||
{
|
||||
...options,
|
||||
stdin: undefined,
|
||||
stdout: undefined,
|
||||
stderr: undefined,
|
||||
stdio,
|
||||
shell: false
|
||||
}
|
||||
);
|
||||
};
|
52
node_modules/default-gateway/node_modules/execa/lib/stdio.js
generated
vendored
Normal file
52
node_modules/default-gateway/node_modules/execa/lib/stdio.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
'use strict';
|
||||
const aliases = ['stdin', 'stdout', 'stderr'];
|
||||
|
||||
const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
|
||||
|
||||
const normalizeStdio = options => {
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {stdio} = options;
|
||||
|
||||
if (stdio === undefined) {
|
||||
return aliases.map(alias => options[alias]);
|
||||
}
|
||||
|
||||
if (hasAlias(options)) {
|
||||
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
|
||||
}
|
||||
|
||||
if (typeof stdio === 'string') {
|
||||
return stdio;
|
||||
}
|
||||
|
||||
if (!Array.isArray(stdio)) {
|
||||
throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
|
||||
}
|
||||
|
||||
const length = Math.max(stdio.length, aliases.length);
|
||||
return Array.from({length}, (value, index) => stdio[index]);
|
||||
};
|
||||
|
||||
module.exports = normalizeStdio;
|
||||
|
||||
// `ipc` is pushed unless it is already present
|
||||
module.exports.node = options => {
|
||||
const stdio = normalizeStdio(options);
|
||||
|
||||
if (stdio === 'ipc') {
|
||||
return 'ipc';
|
||||
}
|
||||
|
||||
if (stdio === undefined || typeof stdio === 'string') {
|
||||
return [stdio, stdio, stdio, 'ipc'];
|
||||
}
|
||||
|
||||
if (stdio.includes('ipc')) {
|
||||
return stdio;
|
||||
}
|
||||
|
||||
return [...stdio, 'ipc'];
|
||||
};
|
9
node_modules/default-gateway/node_modules/execa/license
generated
vendored
Normal file
9
node_modules/default-gateway/node_modules/execa/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://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.
|
74
node_modules/default-gateway/node_modules/execa/package.json
generated
vendored
Normal file
74
node_modules/default-gateway/node_modules/execa/package.json
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"name": "execa",
|
||||
"version": "5.1.1",
|
||||
"description": "Process execution for humans",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/execa",
|
||||
"funding": "https://github.com/sindresorhus/execa?sponsor=1",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"lib"
|
||||
],
|
||||
"keywords": [
|
||||
"exec",
|
||||
"child",
|
||||
"process",
|
||||
"execute",
|
||||
"fork",
|
||||
"execfile",
|
||||
"spawn",
|
||||
"file",
|
||||
"shell",
|
||||
"bin",
|
||||
"binary",
|
||||
"binaries",
|
||||
"npm",
|
||||
"path",
|
||||
"local"
|
||||
],
|
||||
"dependencies": {
|
||||
"cross-spawn": "^7.0.3",
|
||||
"get-stream": "^6.0.0",
|
||||
"human-signals": "^2.1.0",
|
||||
"is-stream": "^2.0.0",
|
||||
"merge-stream": "^2.0.0",
|
||||
"npm-run-path": "^4.0.1",
|
||||
"onetime": "^5.1.2",
|
||||
"signal-exit": "^3.0.3",
|
||||
"strip-final-newline": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.14.10",
|
||||
"ava": "^2.4.0",
|
||||
"get-node": "^11.0.1",
|
||||
"is-running": "^2.1.0",
|
||||
"nyc": "^15.1.0",
|
||||
"p-event": "^4.2.0",
|
||||
"tempfile": "^3.0.0",
|
||||
"tsd": "^0.13.1",
|
||||
"xo": "^0.35.0"
|
||||
},
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
"text",
|
||||
"lcov"
|
||||
],
|
||||
"exclude": [
|
||||
"**/fixtures/**",
|
||||
"**/test.js",
|
||||
"**/test/**"
|
||||
]
|
||||
}
|
||||
}
|
663
node_modules/default-gateway/node_modules/execa/readme.md
generated
vendored
Normal file
663
node_modules/default-gateway/node_modules/execa/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,663 @@
|
|||
<img src="media/logo.svg" width="400">
|
||||
<br>
|
||||
|
||||
[](https://codecov.io/gh/sindresorhus/execa)
|
||||
|
||||
> Process execution for humans
|
||||
|
||||
## Why
|
||||
|
||||
This package improves [`child_process`](https://nodejs.org/api/child_process.html) methods with:
|
||||
|
||||
- Promise interface.
|
||||
- [Strips the final newline](#stripfinalnewline) from the output so you don't have to do `stdout.trim()`.
|
||||
- Supports [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) binaries cross-platform.
|
||||
- [Improved Windows support.](https://github.com/IndigoUnited/node-cross-spawn#why)
|
||||
- Higher max buffer. 100 MB instead of 200 KB.
|
||||
- [Executes locally installed binaries by name.](#preferlocal)
|
||||
- [Cleans up spawned processes when the parent process dies.](#cleanup)
|
||||
- [Get interleaved output](#all) from `stdout` and `stderr` similar to what is printed on the terminal. [*(Async only)*](#execasyncfile-arguments-options)
|
||||
- [Can specify file and arguments as a single string without a shell](#execacommandcommand-options)
|
||||
- More descriptive errors.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install execa
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const execa = require('execa');
|
||||
|
||||
(async () => {
|
||||
const {stdout} = await execa('echo', ['unicorns']);
|
||||
console.log(stdout);
|
||||
//=> 'unicorns'
|
||||
})();
|
||||
```
|
||||
|
||||
### Pipe the child process stdout to the parent
|
||||
|
||||
```js
|
||||
const execa = require('execa');
|
||||
|
||||
execa('echo', ['unicorns']).stdout.pipe(process.stdout);
|
||||
```
|
||||
|
||||
### Handling Errors
|
||||
|
||||
```js
|
||||
const execa = require('execa');
|
||||
|
||||
(async () => {
|
||||
// Catching an error
|
||||
try {
|
||||
await execa('unknown', ['command']);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
/*
|
||||
{
|
||||
message: 'Command failed with ENOENT: unknown command spawn unknown ENOENT',
|
||||
errno: -2,
|
||||
code: 'ENOENT',
|
||||
syscall: 'spawn unknown',
|
||||
path: 'unknown',
|
||||
spawnargs: ['command'],
|
||||
originalMessage: 'spawn unknown ENOENT',
|
||||
shortMessage: 'Command failed with ENOENT: unknown command spawn unknown ENOENT',
|
||||
command: 'unknown command',
|
||||
escapedCommand: 'unknown command',
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
all: '',
|
||||
failed: true,
|
||||
timedOut: false,
|
||||
isCanceled: false,
|
||||
killed: false
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
})();
|
||||
```
|
||||
|
||||
### Cancelling a spawned process
|
||||
|
||||
```js
|
||||
const execa = require('execa');
|
||||
|
||||
(async () => {
|
||||
const subprocess = execa('node');
|
||||
|
||||
setTimeout(() => {
|
||||
subprocess.cancel();
|
||||
}, 1000);
|
||||
|
||||
try {
|
||||
await subprocess;
|
||||
} catch (error) {
|
||||
console.log(subprocess.killed); // true
|
||||
console.log(error.isCanceled); // true
|
||||
}
|
||||
})()
|
||||
```
|
||||
|
||||
### Catching an error with the sync method
|
||||
|
||||
```js
|
||||
try {
|
||||
execa.sync('unknown', ['command']);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
/*
|
||||
{
|
||||
message: 'Command failed with ENOENT: unknown command spawnSync unknown ENOENT',
|
||||
errno: -2,
|
||||
code: 'ENOENT',
|
||||
syscall: 'spawnSync unknown',
|
||||
path: 'unknown',
|
||||
spawnargs: ['command'],
|
||||
originalMessage: 'spawnSync unknown ENOENT',
|
||||
shortMessage: 'Command failed with ENOENT: unknown command spawnSync unknown ENOENT',
|
||||
command: 'unknown command',
|
||||
escapedCommand: 'unknown command',
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
all: '',
|
||||
failed: true,
|
||||
timedOut: false,
|
||||
isCanceled: false,
|
||||
killed: false
|
||||
}
|
||||
*/
|
||||
}
|
||||
```
|
||||
|
||||
### Kill a process
|
||||
|
||||
Using SIGTERM, and after 2 seconds, kill it with SIGKILL.
|
||||
|
||||
```js
|
||||
const subprocess = execa('node');
|
||||
|
||||
setTimeout(() => {
|
||||
subprocess.kill('SIGTERM', {
|
||||
forceKillAfterTimeout: 2000
|
||||
});
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### execa(file, arguments, options?)
|
||||
|
||||
Execute a file. Think of this as a mix of [`child_process.execFile()`](https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback) and [`child_process.spawn()`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).
|
||||
|
||||
No escaping/quoting is needed.
|
||||
|
||||
Unless the [`shell`](#shell) option is used, no shell interpreter (Bash, `cmd.exe`, etc.) is used, so shell features such as variables substitution (`echo $PATH`) are not allowed.
|
||||
|
||||
Returns a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) which:
|
||||
- is also a `Promise` resolving or rejecting with a [`childProcessResult`](#childProcessResult).
|
||||
- exposes the following additional methods and properties.
|
||||
|
||||
#### kill(signal?, options?)
|
||||
|
||||
Same as the original [`child_process#kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal) except: if `signal` is `SIGTERM` (the default value) and the child process is not terminated after 5 seconds, force it by sending `SIGKILL`.
|
||||
|
||||
##### options.forceKillAfterTimeout
|
||||
|
||||
Type: `number | false`\
|
||||
Default: `5000`
|
||||
|
||||
Milliseconds to wait for the child process to terminate before sending `SIGKILL`.
|
||||
|
||||
Can be disabled with `false`.
|
||||
|
||||
#### cancel()
|
||||
|
||||
Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This is preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`.
|
||||
|
||||
#### all
|
||||
|
||||
Type: `ReadableStream | undefined`
|
||||
|
||||
Stream combining/interleaving [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).
|
||||
|
||||
This is `undefined` if either:
|
||||
- the [`all` option](#all-2) is `false` (the default value)
|
||||
- both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio)
|
||||
|
||||
### execa.sync(file, arguments?, options?)
|
||||
|
||||
Execute a file synchronously.
|
||||
|
||||
Returns or throws a [`childProcessResult`](#childProcessResult).
|
||||
|
||||
### execa.command(command, options?)
|
||||
|
||||
Same as [`execa()`](#execafile-arguments-options) except both file and arguments are specified in a single `command` string. For example, `execa('echo', ['unicorns'])` is the same as `execa.command('echo unicorns')`.
|
||||
|
||||
If the file or an argument contains spaces, they must be escaped with backslashes. This matters especially if `command` is not a constant but a variable, for example with `__dirname` or `process.cwd()`. Except for spaces, no escaping/quoting is needed.
|
||||
|
||||
The [`shell` option](#shell) must be used if the `command` uses shell-specific features (for example, `&&` or `||`), as opposed to being a simple `file` followed by its `arguments`.
|
||||
|
||||
### execa.commandSync(command, options?)
|
||||
|
||||
Same as [`execa.command()`](#execacommand-command-options) but synchronous.
|
||||
|
||||
Returns or throws a [`childProcessResult`](#childProcessResult).
|
||||
|
||||
### execa.node(scriptPath, arguments?, options?)
|
||||
|
||||
Execute a Node.js script as a child process.
|
||||
|
||||
Same as `execa('node', [scriptPath, ...arguments], options)` except (like [`child_process#fork()`](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options)):
|
||||
- the current Node version and options are used. This can be overridden using the [`nodePath`](#nodepath-for-node-only) and [`nodeOptions`](#nodeoptions-for-node-only) options.
|
||||
- the [`shell`](#shell) option cannot be used
|
||||
- an extra channel [`ipc`](https://nodejs.org/api/child_process.html#child_process_options_stdio) is passed to [`stdio`](#stdio)
|
||||
|
||||
### childProcessResult
|
||||
|
||||
Type: `object`
|
||||
|
||||
Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.
|
||||
|
||||
The child process [fails](#failed) when:
|
||||
- its [exit code](#exitcode) is not `0`
|
||||
- it was [killed](#killed) with a [signal](#signal)
|
||||
- [timing out](#timedout)
|
||||
- [being canceled](#iscanceled)
|
||||
- there's not enough memory or there are already too many child processes
|
||||
|
||||
#### command
|
||||
|
||||
Type: `string`
|
||||
|
||||
The file and arguments that were run, for logging purposes.
|
||||
|
||||
This is not escaped and should not be executed directly as a process, including using [`execa()`](#execafile-arguments-options) or [`execa.command()`](#execacommandcommand-options).
|
||||
|
||||
#### escapedCommand
|
||||
|
||||
Type: `string`
|
||||
|
||||
Same as [`command`](#command) but escaped.
|
||||
|
||||
This is meant to be copy and pasted into a shell, for debugging purposes.
|
||||
Since the escaping is fairly basic, this should not be executed directly as a process, including using [`execa()`](#execafile-arguments-options) or [`execa.command()`](#execacommandcommand-options).
|
||||
|
||||
#### exitCode
|
||||
|
||||
Type: `number`
|
||||
|
||||
The numeric exit code of the process that was run.
|
||||
|
||||
#### stdout
|
||||
|
||||
Type: `string | Buffer`
|
||||
|
||||
The output of the process on stdout.
|
||||
|
||||
#### stderr
|
||||
|
||||
Type: `string | Buffer`
|
||||
|
||||
The output of the process on stderr.
|
||||
|
||||
#### all
|
||||
|
||||
Type: `string | Buffer | undefined`
|
||||
|
||||
The output of the process with `stdout` and `stderr` interleaved.
|
||||
|
||||
This is `undefined` if either:
|
||||
- the [`all` option](#all-2) is `false` (the default value)
|
||||
- `execa.sync()` was used
|
||||
|
||||
#### failed
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Whether the process failed to run.
|
||||
|
||||
#### timedOut
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Whether the process timed out.
|
||||
|
||||
#### isCanceled
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Whether the process was canceled.
|
||||
|
||||
#### killed
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Whether the process was killed.
|
||||
|
||||
#### signal
|
||||
|
||||
Type: `string | undefined`
|
||||
|
||||
The name of the signal that was used to terminate the process. For example, `SIGFPE`.
|
||||
|
||||
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`.
|
||||
|
||||
#### signalDescription
|
||||
|
||||
Type: `string | undefined`
|
||||
|
||||
A human-friendly description of the signal that was used to terminate the process. For example, `Floating point arithmetic error`.
|
||||
|
||||
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`. It is also `undefined` when the signal is very uncommon which should seldomly happen.
|
||||
|
||||
#### message
|
||||
|
||||
Type: `string`
|
||||
|
||||
Error message when the child process failed to run. In addition to the [underlying error message](#originalMessage), it also contains some information related to why the child process errored.
|
||||
|
||||
The child process [stderr](#stderr) then [stdout](#stdout) are appended to the end, separated with newlines and not interleaved.
|
||||
|
||||
#### shortMessage
|
||||
|
||||
Type: `string`
|
||||
|
||||
This is the same as the [`message` property](#message) except it does not include the child process stdout/stderr.
|
||||
|
||||
#### originalMessage
|
||||
|
||||
Type: `string | undefined`
|
||||
|
||||
Original error message. This is the same as the `message` property except it includes neither the child process stdout/stderr nor some additional information added by Execa.
|
||||
|
||||
This is `undefined` unless the child process exited due to an `error` event or a timeout.
|
||||
|
||||
### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
#### cleanup
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Kill the spawned process when the parent process exits unless either:
|
||||
- the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)
|
||||
- the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit
|
||||
|
||||
#### preferLocal
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Prefer locally installed binaries when looking for a binary to execute.\
|
||||
If you `$ npm install foo`, you can then `execa('foo')`.
|
||||
|
||||
#### localDir
|
||||
|
||||
Type: `string`\
|
||||
Default: `process.cwd()`
|
||||
|
||||
Preferred path to find locally installed binaries in (use with `preferLocal`).
|
||||
|
||||
#### execPath
|
||||
|
||||
Type: `string`\
|
||||
Default: `process.execPath` (Current Node.js executable)
|
||||
|
||||
Path to the Node.js executable to use in child processes.
|
||||
|
||||
This can be either an absolute path or a path relative to the [`cwd` option](#cwd).
|
||||
|
||||
Requires [`preferLocal`](#preferlocal) to be `true`.
|
||||
|
||||
For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.
|
||||
|
||||
#### buffer
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Buffer the output from the spawned process. When set to `false`, you must read the output of [`stdout`](#stdout-1) and [`stderr`](#stderr-1) (or [`all`](#all) if the [`all`](#all-2) option is `true`). Otherwise the returned promise will not be resolved/rejected.
|
||||
|
||||
If the spawned process fails, [`error.stdout`](#stdout), [`error.stderr`](#stderr), and [`error.all`](#all) will contain the buffered data.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `string | Buffer | stream.Readable`
|
||||
|
||||
Write some input to the `stdin` of your binary.\
|
||||
Streams are not allowed when using the synchronous methods.
|
||||
|
||||
#### stdin
|
||||
|
||||
Type: `string | number | Stream | undefined`\
|
||||
Default: `pipe`
|
||||
|
||||
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
||||
|
||||
#### stdout
|
||||
|
||||
Type: `string | number | Stream | undefined`\
|
||||
Default: `pipe`
|
||||
|
||||
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
||||
|
||||
#### stderr
|
||||
|
||||
Type: `string | number | Stream | undefined`\
|
||||
Default: `pipe`
|
||||
|
||||
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
||||
|
||||
#### all
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Add an `.all` property on the [promise](#all) and the [resolved value](#all-1). The property contains the output of the process with `stdout` and `stderr` interleaved.
|
||||
|
||||
#### reject
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Setting this to `false` resolves the promise with the error instead of rejecting it.
|
||||
|
||||
#### stripFinalNewline
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.
|
||||
|
||||
#### extendEnv
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Set to `false` if you don't want to extend the environment variables when providing the `env` property.
|
||||
|
||||
---
|
||||
|
||||
Execa also accepts the below options which are the same as the options for [`child_process#spawn()`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)/[`child_process#exec()`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)
|
||||
|
||||
#### cwd
|
||||
|
||||
Type: `string`\
|
||||
Default: `process.cwd()`
|
||||
|
||||
Current working directory of the child process.
|
||||
|
||||
#### env
|
||||
|
||||
Type: `object`\
|
||||
Default: `process.env`
|
||||
|
||||
Environment key-value pairs. Extends automatically from `process.env`. Set [`extendEnv`](#extendenv) to `false` if you don't want this.
|
||||
|
||||
#### argv0
|
||||
|
||||
Type: `string`
|
||||
|
||||
Explicitly set the value of `argv[0]` sent to the child process. This will be set to `file` if not specified.
|
||||
|
||||
#### stdio
|
||||
|
||||
Type: `string | string[]`\
|
||||
Default: `pipe`
|
||||
|
||||
Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.
|
||||
|
||||
#### serialization
|
||||
|
||||
Type: `string`\
|
||||
Default: `'json'`
|
||||
|
||||
Specify the kind of serialization used for sending messages between processes when using the [`stdio: 'ipc'`](#stdio) option or [`execa.node()`](#execanodescriptpath-arguments-options):
|
||||
- `json`: Uses `JSON.stringify()` and `JSON.parse()`.
|
||||
- `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
|
||||
|
||||
Requires Node.js `13.2.0` or later.
|
||||
|
||||
[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)
|
||||
|
||||
#### detached
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).
|
||||
|
||||
#### uid
|
||||
|
||||
Type: `number`
|
||||
|
||||
Sets the user identity of the process.
|
||||
|
||||
#### gid
|
||||
|
||||
Type: `number`
|
||||
|
||||
Sets the group identity of the process.
|
||||
|
||||
#### shell
|
||||
|
||||
Type: `boolean | string`\
|
||||
Default: `false`
|
||||
|
||||
If `true`, runs `file` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
|
||||
|
||||
We recommend against using this option since it is:
|
||||
- not cross-platform, encouraging shell-specific syntax.
|
||||
- slower, because of the additional shell interpretation.
|
||||
- unsafe, potentially allowing command injection.
|
||||
|
||||
#### encoding
|
||||
|
||||
Type: `string | null`\
|
||||
Default: `utf8`
|
||||
|
||||
Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.
|
||||
|
||||
#### timeout
|
||||
|
||||
Type: `number`\
|
||||
Default: `0`
|
||||
|
||||
If timeout is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than timeout milliseconds.
|
||||
|
||||
#### maxBuffer
|
||||
|
||||
Type: `number`\
|
||||
Default: `100_000_000` (100 MB)
|
||||
|
||||
Largest amount of data in bytes allowed on `stdout` or `stderr`.
|
||||
|
||||
#### killSignal
|
||||
|
||||
Type: `string | number`\
|
||||
Default: `SIGTERM`
|
||||
|
||||
Signal value to be used when the spawned process will be killed.
|
||||
|
||||
#### windowsVerbatimArguments
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.
|
||||
|
||||
#### windowsHide
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
On Windows, do not create a new console window. Please note this also prevents `CTRL-C` [from working](https://github.com/nodejs/node/issues/29837) on Windows.
|
||||
|
||||
#### nodePath *(For `.node()` only)*
|
||||
|
||||
Type: `string`\
|
||||
Default: [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath)
|
||||
|
||||
Node.js executable used to create the child process.
|
||||
|
||||
#### nodeOptions *(For `.node()` only)*
|
||||
|
||||
Type: `string[]`\
|
||||
Default: [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv)
|
||||
|
||||
List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.
|
||||
|
||||
## Tips
|
||||
|
||||
### Retry on error
|
||||
|
||||
Gracefully handle failures by using automatic retries and exponential backoff with the [`p-retry`](https://github.com/sindresorhus/p-retry) package:
|
||||
|
||||
```js
|
||||
const pRetry = require('p-retry');
|
||||
|
||||
const run = async () => {
|
||||
const results = await execa('curl', ['-sSL', 'https://sindresorhus.com/unicorn']);
|
||||
return results;
|
||||
};
|
||||
|
||||
(async () => {
|
||||
console.log(await pRetry(run, {retries: 5}));
|
||||
})();
|
||||
```
|
||||
|
||||
### Save and pipe output from a child process
|
||||
|
||||
Let's say you want to show the output of a child process in real-time while also saving it to a variable.
|
||||
|
||||
```js
|
||||
const execa = require('execa');
|
||||
|
||||
const subprocess = execa('echo', ['foo']);
|
||||
subprocess.stdout.pipe(process.stdout);
|
||||
|
||||
(async () => {
|
||||
const {stdout} = await subprocess;
|
||||
console.log('child output:', stdout);
|
||||
})();
|
||||
```
|
||||
|
||||
### Redirect output to a file
|
||||
|
||||
```js
|
||||
const execa = require('execa');
|
||||
|
||||
const subprocess = execa('echo', ['foo'])
|
||||
subprocess.stdout.pipe(fs.createWriteStream('stdout.txt'))
|
||||
```
|
||||
|
||||
### Redirect input from a file
|
||||
|
||||
```js
|
||||
const execa = require('execa');
|
||||
|
||||
const subprocess = execa('cat')
|
||||
fs.createReadStream('stdin.txt').pipe(subprocess.stdin)
|
||||
```
|
||||
|
||||
### Execute the current package's binary
|
||||
|
||||
```js
|
||||
const {getBinPathSync} = require('get-bin-path');
|
||||
|
||||
const binPath = getBinPathSync();
|
||||
const subprocess = execa(binPath);
|
||||
```
|
||||
|
||||
`execa` can be combined with [`get-bin-path`](https://github.com/ehmicky/get-bin-path) to test the current package's binary. As opposed to hard-coding the path to the binary, this validates that the `package.json` `bin` field is correctly set up.
|
||||
|
||||
## Related
|
||||
|
||||
- [gulp-execa](https://github.com/ehmicky/gulp-execa) - Gulp plugin for `execa`
|
||||
- [nvexeca](https://github.com/ehmicky/nvexeca) - Run `execa` using any Node.js version
|
||||
- [sudo-prompt](https://github.com/jorangreef/sudo-prompt) - Run commands with elevated privileges.
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [@ehmicky](https://github.com/ehmicky)
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-execa?utm_source=npm-execa&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
47
node_modules/default-gateway/node_modules/npm-run-path/index.js
generated
vendored
Normal file
47
node_modules/default-gateway/node_modules/npm-run-path/index.js
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const pathKey = require('path-key');
|
||||
|
||||
const npmRunPath = options => {
|
||||
options = {
|
||||
cwd: process.cwd(),
|
||||
path: process.env[pathKey()],
|
||||
execPath: process.execPath,
|
||||
...options
|
||||
};
|
||||
|
||||
let previous;
|
||||
let cwdPath = path.resolve(options.cwd);
|
||||
const result = [];
|
||||
|
||||
while (previous !== cwdPath) {
|
||||
result.push(path.join(cwdPath, 'node_modules/.bin'));
|
||||
previous = cwdPath;
|
||||
cwdPath = path.resolve(cwdPath, '..');
|
||||
}
|
||||
|
||||
// Ensure the running `node` binary is used
|
||||
const execPathDir = path.resolve(options.cwd, options.execPath, '..');
|
||||
result.push(execPathDir);
|
||||
|
||||
return result.concat(options.path).join(path.delimiter);
|
||||
};
|
||||
|
||||
module.exports = npmRunPath;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = npmRunPath;
|
||||
|
||||
module.exports.env = options => {
|
||||
options = {
|
||||
env: process.env,
|
||||
...options
|
||||
};
|
||||
|
||||
const env = {...options.env};
|
||||
const path = pathKey({env});
|
||||
|
||||
options.path = env[path];
|
||||
env[path] = module.exports(options);
|
||||
|
||||
return env;
|
||||
};
|
9
node_modules/default-gateway/node_modules/npm-run-path/license
generated
vendored
Normal file
9
node_modules/default-gateway/node_modules/npm-run-path/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.
|
44
node_modules/default-gateway/node_modules/npm-run-path/package.json
generated
vendored
Normal file
44
node_modules/default-gateway/node_modules/npm-run-path/package.json
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "npm-run-path",
|
||||
"version": "4.0.1",
|
||||
"description": "Get your PATH prepended with locally installed binaries",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/npm-run-path",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"npm",
|
||||
"run",
|
||||
"path",
|
||||
"package",
|
||||
"bin",
|
||||
"binary",
|
||||
"binaries",
|
||||
"script",
|
||||
"cli",
|
||||
"command-line",
|
||||
"execute",
|
||||
"executable"
|
||||
],
|
||||
"dependencies": {
|
||||
"path-key": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
115
node_modules/default-gateway/node_modules/npm-run-path/readme.md
generated
vendored
Normal file
115
node_modules/default-gateway/node_modules/npm-run-path/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
# npm-run-path [](https://travis-ci.org/sindresorhus/npm-run-path)
|
||||
|
||||
> Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries
|
||||
|
||||
In [npm run scripts](https://docs.npmjs.com/cli/run-script) you can execute locally installed binaries by name. This enables the same outside npm.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install npm-run-path
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const childProcess = require('child_process');
|
||||
const npmRunPath = require('npm-run-path');
|
||||
|
||||
console.log(process.env.PATH);
|
||||
//=> '/usr/local/bin'
|
||||
|
||||
console.log(npmRunPath());
|
||||
//=> '/Users/sindresorhus/dev/foo/node_modules/.bin:/Users/sindresorhus/dev/node_modules/.bin:/Users/sindresorhus/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/bin'
|
||||
|
||||
// `foo` is a locally installed binary
|
||||
childProcess.execFileSync('foo', {
|
||||
env: npmRunPath.env()
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### npmRunPath(options?)
|
||||
|
||||
Returns the augmented path string.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Working directory.
|
||||
|
||||
##### path
|
||||
|
||||
Type: `string`<br>
|
||||
Default: [`PATH`](https://github.com/sindresorhus/path-key)
|
||||
|
||||
PATH to be appended.<br>
|
||||
Set it to an empty string to exclude the default PATH.
|
||||
|
||||
##### execPath
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.execPath`
|
||||
|
||||
Path to the current Node.js executable. Its directory is pushed to the front of PATH.
|
||||
|
||||
This can be either an absolute path or a path relative to the [`cwd` option](#cwd).
|
||||
|
||||
### npmRunPath.env(options?)
|
||||
|
||||
Returns the augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Working directory.
|
||||
|
||||
##### env
|
||||
|
||||
Type: `Object`
|
||||
|
||||
Accepts an object of environment variables, like `process.env`, and modifies the PATH using the correct [PATH key](https://github.com/sindresorhus/path-key). Use this if you're modifying the PATH for use in the `child_process` options.
|
||||
|
||||
##### execPath
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.execPath`
|
||||
|
||||
Path to the Node.js executable to use in child processes if that is different from the current one. Its directory is pushed to the front of PATH.
|
||||
|
||||
This can be either an absolute path or a path relative to the [`cwd` option](#cwd).
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [npm-run-path-cli](https://github.com/sindresorhus/npm-run-path-cli) - CLI for this module
|
||||
- [execa](https://github.com/sindresorhus/execa) - Execute a locally installed binary
|
||||
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-npm-run-path?utm_source=npm-npm-run-path&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
16
node_modules/default-gateway/node_modules/signal-exit/LICENSE.txt
generated
vendored
Normal file
16
node_modules/default-gateway/node_modules/signal-exit/LICENSE.txt
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
The ISC License
|
||||
|
||||
Copyright (c) 2015, Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice
|
||||
appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
39
node_modules/default-gateway/node_modules/signal-exit/README.md
generated
vendored
Normal file
39
node_modules/default-gateway/node_modules/signal-exit/README.md
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
# signal-exit
|
||||
|
||||
[](https://travis-ci.org/tapjs/signal-exit)
|
||||
[](https://coveralls.io/r/tapjs/signal-exit?branch=master)
|
||||
[](https://www.npmjs.com/package/signal-exit)
|
||||
[](https://github.com/conventional-changelog/standard-version)
|
||||
|
||||
When you want to fire an event no matter how a process exits:
|
||||
|
||||
* reaching the end of execution.
|
||||
* explicitly having `process.exit(code)` called.
|
||||
* having `process.kill(pid, sig)` called.
|
||||
* receiving a fatal signal from outside the process
|
||||
|
||||
Use `signal-exit`.
|
||||
|
||||
```js
|
||||
var onExit = require('signal-exit')
|
||||
|
||||
onExit(function (code, signal) {
|
||||
console.log('process exited!')
|
||||
})
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
`var remove = onExit(function (code, signal) {}, options)`
|
||||
|
||||
The return value of the function is a function that will remove the
|
||||
handler.
|
||||
|
||||
Note that the function *only* fires for signals if the signal would
|
||||
cause the process to exit. That is, there are no other listeners, and
|
||||
it is a fatal signal.
|
||||
|
||||
## Options
|
||||
|
||||
* `alwaysLast`: Run this handler after any other signal or exit
|
||||
handlers. This causes `process.emit` to be monkeypatched.
|
202
node_modules/default-gateway/node_modules/signal-exit/index.js
generated
vendored
Normal file
202
node_modules/default-gateway/node_modules/signal-exit/index.js
generated
vendored
Normal file
|
@ -0,0 +1,202 @@
|
|||
// Note: since nyc uses this module to output coverage, any lines
|
||||
// that are in the direct sync flow of nyc's outputCoverage are
|
||||
// ignored, since we can never get coverage for them.
|
||||
// grab a reference to node's real process object right away
|
||||
var process = global.process
|
||||
|
||||
const processOk = function (process) {
|
||||
return process &&
|
||||
typeof process === 'object' &&
|
||||
typeof process.removeListener === 'function' &&
|
||||
typeof process.emit === 'function' &&
|
||||
typeof process.reallyExit === 'function' &&
|
||||
typeof process.listeners === 'function' &&
|
||||
typeof process.kill === 'function' &&
|
||||
typeof process.pid === 'number' &&
|
||||
typeof process.on === 'function'
|
||||
}
|
||||
|
||||
// some kind of non-node environment, just no-op
|
||||
/* istanbul ignore if */
|
||||
if (!processOk(process)) {
|
||||
module.exports = function () {
|
||||
return function () {}
|
||||
}
|
||||
} else {
|
||||
var assert = require('assert')
|
||||
var signals = require('./signals.js')
|
||||
var isWin = /^win/i.test(process.platform)
|
||||
|
||||
var EE = require('events')
|
||||
/* istanbul ignore if */
|
||||
if (typeof EE !== 'function') {
|
||||
EE = EE.EventEmitter
|
||||
}
|
||||
|
||||
var emitter
|
||||
if (process.__signal_exit_emitter__) {
|
||||
emitter = process.__signal_exit_emitter__
|
||||
} else {
|
||||
emitter = process.__signal_exit_emitter__ = new EE()
|
||||
emitter.count = 0
|
||||
emitter.emitted = {}
|
||||
}
|
||||
|
||||
// Because this emitter is a global, we have to check to see if a
|
||||
// previous version of this library failed to enable infinite listeners.
|
||||
// I know what you're about to say. But literally everything about
|
||||
// signal-exit is a compromise with evil. Get used to it.
|
||||
if (!emitter.infinite) {
|
||||
emitter.setMaxListeners(Infinity)
|
||||
emitter.infinite = true
|
||||
}
|
||||
|
||||
module.exports = function (cb, opts) {
|
||||
/* istanbul ignore if */
|
||||
if (!processOk(global.process)) {
|
||||
return function () {}
|
||||
}
|
||||
assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')
|
||||
|
||||
if (loaded === false) {
|
||||
load()
|
||||
}
|
||||
|
||||
var ev = 'exit'
|
||||
if (opts && opts.alwaysLast) {
|
||||
ev = 'afterexit'
|
||||
}
|
||||
|
||||
var remove = function () {
|
||||
emitter.removeListener(ev, cb)
|
||||
if (emitter.listeners('exit').length === 0 &&
|
||||
emitter.listeners('afterexit').length === 0) {
|
||||
unload()
|
||||
}
|
||||
}
|
||||
emitter.on(ev, cb)
|
||||
|
||||
return remove
|
||||
}
|
||||
|
||||
var unload = function unload () {
|
||||
if (!loaded || !processOk(global.process)) {
|
||||
return
|
||||
}
|
||||
loaded = false
|
||||
|
||||
signals.forEach(function (sig) {
|
||||
try {
|
||||
process.removeListener(sig, sigListeners[sig])
|
||||
} catch (er) {}
|
||||
})
|
||||
process.emit = originalProcessEmit
|
||||
process.reallyExit = originalProcessReallyExit
|
||||
emitter.count -= 1
|
||||
}
|
||||
module.exports.unload = unload
|
||||
|
||||
var emit = function emit (event, code, signal) {
|
||||
/* istanbul ignore if */
|
||||
if (emitter.emitted[event]) {
|
||||
return
|
||||
}
|
||||
emitter.emitted[event] = true
|
||||
emitter.emit(event, code, signal)
|
||||
}
|
||||
|
||||
// { <signal>: <listener fn>, ... }
|
||||
var sigListeners = {}
|
||||
signals.forEach(function (sig) {
|
||||
sigListeners[sig] = function listener () {
|
||||
/* istanbul ignore if */
|
||||
if (!processOk(global.process)) {
|
||||
return
|
||||
}
|
||||
// If there are no other listeners, an exit is coming!
|
||||
// Simplest way: remove us and then re-send the signal.
|
||||
// We know that this will kill the process, so we can
|
||||
// safely emit now.
|
||||
var listeners = process.listeners(sig)
|
||||
if (listeners.length === emitter.count) {
|
||||
unload()
|
||||
emit('exit', null, sig)
|
||||
/* istanbul ignore next */
|
||||
emit('afterexit', null, sig)
|
||||
/* istanbul ignore next */
|
||||
if (isWin && sig === 'SIGHUP') {
|
||||
// "SIGHUP" throws an `ENOSYS` error on Windows,
|
||||
// so use a supported signal instead
|
||||
sig = 'SIGINT'
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
process.kill(process.pid, sig)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
module.exports.signals = function () {
|
||||
return signals
|
||||
}
|
||||
|
||||
var loaded = false
|
||||
|
||||
var load = function load () {
|
||||
if (loaded || !processOk(global.process)) {
|
||||
return
|
||||
}
|
||||
loaded = true
|
||||
|
||||
// This is the number of onSignalExit's that are in play.
|
||||
// It's important so that we can count the correct number of
|
||||
// listeners on signals, and don't wait for the other one to
|
||||
// handle it instead of us.
|
||||
emitter.count += 1
|
||||
|
||||
signals = signals.filter(function (sig) {
|
||||
try {
|
||||
process.on(sig, sigListeners[sig])
|
||||
return true
|
||||
} catch (er) {
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
process.emit = processEmit
|
||||
process.reallyExit = processReallyExit
|
||||
}
|
||||
module.exports.load = load
|
||||
|
||||
var originalProcessReallyExit = process.reallyExit
|
||||
var processReallyExit = function processReallyExit (code) {
|
||||
/* istanbul ignore if */
|
||||
if (!processOk(global.process)) {
|
||||
return
|
||||
}
|
||||
process.exitCode = code || /* istanbul ignore next */ 0
|
||||
emit('exit', process.exitCode, null)
|
||||
/* istanbul ignore next */
|
||||
emit('afterexit', process.exitCode, null)
|
||||
/* istanbul ignore next */
|
||||
originalProcessReallyExit.call(process, process.exitCode)
|
||||
}
|
||||
|
||||
var originalProcessEmit = process.emit
|
||||
var processEmit = function processEmit (ev, arg) {
|
||||
if (ev === 'exit' && processOk(global.process)) {
|
||||
/* istanbul ignore else */
|
||||
if (arg !== undefined) {
|
||||
process.exitCode = arg
|
||||
}
|
||||
var ret = originalProcessEmit.apply(this, arguments)
|
||||
/* istanbul ignore next */
|
||||
emit('exit', process.exitCode, null)
|
||||
/* istanbul ignore next */
|
||||
emit('afterexit', process.exitCode, null)
|
||||
/* istanbul ignore next */
|
||||
return ret
|
||||
} else {
|
||||
return originalProcessEmit.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
}
|
38
node_modules/default-gateway/node_modules/signal-exit/package.json
generated
vendored
Normal file
38
node_modules/default-gateway/node_modules/signal-exit/package.json
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "signal-exit",
|
||||
"version": "3.0.7",
|
||||
"description": "when you want to fire an event no matter how a process exits.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "tap",
|
||||
"snap": "tap",
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish",
|
||||
"prepublishOnly": "git push origin --follow-tags"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"signals.js"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tapjs/signal-exit.git"
|
||||
},
|
||||
"keywords": [
|
||||
"signal",
|
||||
"exit"
|
||||
],
|
||||
"author": "Ben Coe <ben@npmjs.com>",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/tapjs/signal-exit/issues"
|
||||
},
|
||||
"homepage": "https://github.com/tapjs/signal-exit",
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"coveralls": "^3.1.1",
|
||||
"nyc": "^15.1.0",
|
||||
"standard-version": "^9.3.1",
|
||||
"tap": "^15.1.1"
|
||||
}
|
||||
}
|
53
node_modules/default-gateway/node_modules/signal-exit/signals.js
generated
vendored
Normal file
53
node_modules/default-gateway/node_modules/signal-exit/signals.js
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
// This is not the set of all possible signals.
|
||||
//
|
||||
// It IS, however, the set of all signals that trigger
|
||||
// an exit on either Linux or BSD systems. Linux is a
|
||||
// superset of the signal names supported on BSD, and
|
||||
// the unknown signals just fail to register, so we can
|
||||
// catch that easily enough.
|
||||
//
|
||||
// Don't bother with SIGKILL. It's uncatchable, which
|
||||
// means that we can't fire any callbacks anyway.
|
||||
//
|
||||
// If a user does happen to register a handler on a non-
|
||||
// fatal signal like SIGWINCH or something, and then
|
||||
// exit, it'll end up firing `process.emit('exit')`, so
|
||||
// the handler will be fired anyway.
|
||||
//
|
||||
// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
||||
// artificially, inherently leave the process in a
|
||||
// state from which it is not safe to try and enter JS
|
||||
// listeners.
|
||||
module.exports = [
|
||||
'SIGABRT',
|
||||
'SIGALRM',
|
||||
'SIGHUP',
|
||||
'SIGINT',
|
||||
'SIGTERM'
|
||||
]
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
module.exports.push(
|
||||
'SIGVTALRM',
|
||||
'SIGXCPU',
|
||||
'SIGXFSZ',
|
||||
'SIGUSR2',
|
||||
'SIGTRAP',
|
||||
'SIGSYS',
|
||||
'SIGQUIT',
|
||||
'SIGIOT'
|
||||
// should detect profiler and enable/disable accordingly.
|
||||
// see #21
|
||||
// 'SIGPROF'
|
||||
)
|
||||
}
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
module.exports.push(
|
||||
'SIGIO',
|
||||
'SIGPOLL',
|
||||
'SIGPWR',
|
||||
'SIGSTKFLT',
|
||||
'SIGUNUSED'
|
||||
)
|
||||
}
|
47
node_modules/default-gateway/openbsd.js
generated
vendored
Normal file
47
node_modules/default-gateway/openbsd.js
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
|
||||
const {isIP} = require("net");
|
||||
const execa = require("execa");
|
||||
const dests = new Set(["default", "0.0.0.0", "0.0.0.0/0", "::", "::/0"]);
|
||||
|
||||
const args = {
|
||||
v4: ["-rn", "-f", "inet"],
|
||||
v6: ["-rn", "-f", "inet6"],
|
||||
};
|
||||
|
||||
const parse = stdout => {
|
||||
let result;
|
||||
|
||||
(stdout || "").trim().split("\n").some(line => {
|
||||
const results = line.split(/ +/) || [];
|
||||
const target = results[0];
|
||||
const gateway = results[1];
|
||||
const iface = results[7];
|
||||
if (dests.has(target) && gateway && isIP(gateway)) {
|
||||
result = {gateway, interface: (iface ? iface : null)};
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
throw new Error("Unable to determine default gateway");
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const promise = async family => {
|
||||
const {stdout} = await execa("netstat", args[family]);
|
||||
return parse(stdout);
|
||||
};
|
||||
|
||||
const sync = family => {
|
||||
const {stdout} = execa.sync("netstat", args[family]);
|
||||
return parse(stdout);
|
||||
};
|
||||
|
||||
module.exports.v4 = () => promise("v4");
|
||||
module.exports.v6 = () => promise("v6");
|
||||
|
||||
module.exports.v4.sync = () => sync("v4");
|
||||
module.exports.v6.sync = () => sync("v6");
|
41
node_modules/default-gateway/package.json
generated
vendored
Normal file
41
node_modules/default-gateway/package.json
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "default-gateway",
|
||||
"version": "6.0.3",
|
||||
"description": "Get the default network gateway, cross-platform.",
|
||||
"author": "silverwind",
|
||||
"repository": "silverwind/default-gateway",
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"android.js",
|
||||
"darwin.js",
|
||||
"freebsd.js",
|
||||
"linux.js",
|
||||
"openbsd.js",
|
||||
"sunos.js",
|
||||
"win32.js",
|
||||
"ibmi.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"execa": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "7.17.0",
|
||||
"eslint-config-silverwind": "27.0.0",
|
||||
"jest": "26.6.3",
|
||||
"updates": "11.4.2",
|
||||
"versions": "8.4.4"
|
||||
},
|
||||
"keywords": [
|
||||
"default gateway",
|
||||
"network",
|
||||
"default",
|
||||
"gateway",
|
||||
"routing",
|
||||
"route"
|
||||
]
|
||||
}
|
47
node_modules/default-gateway/sunos.js
generated
vendored
Normal file
47
node_modules/default-gateway/sunos.js
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
|
||||
const {isIP} = require("net");
|
||||
const execa = require("execa");
|
||||
const dests = new Set(["default", "0.0.0.0", "0.0.0.0/0", "::", "::/0"]);
|
||||
|
||||
const args = {
|
||||
v4: ["-rn", "-f", "inet"],
|
||||
v6: ["-rn", "-f", "inet6"],
|
||||
};
|
||||
|
||||
const parse = stdout => {
|
||||
let result;
|
||||
|
||||
(stdout || "").trim().split("\n").some(line => {
|
||||
const results = line.split(/ +/) || [];
|
||||
const target = results[0];
|
||||
const gateway = results[1];
|
||||
const iface = results[5];
|
||||
if (dests.has(target) && gateway && isIP(gateway)) {
|
||||
result = {gateway, interface: (iface ? iface : null)};
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
throw new Error("Unable to determine default gateway");
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const promise = async family => {
|
||||
const {stdout} = await execa("netstat", args[family]);
|
||||
return parse(stdout);
|
||||
};
|
||||
|
||||
const sync = family => {
|
||||
const {stdout} = execa.sync("netstat", args[family]);
|
||||
return parse(stdout);
|
||||
};
|
||||
|
||||
module.exports.v4 = () => promise("v4");
|
||||
module.exports.v6 = () => promise("v6");
|
||||
|
||||
module.exports.v4.sync = () => sync("v4");
|
||||
module.exports.v6.sync = () => sync("v6");
|
99
node_modules/default-gateway/win32.js
generated
vendored
Normal file
99
node_modules/default-gateway/win32.js
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
"use strict";
|
||||
|
||||
const {isIP} = require("net");
|
||||
const {networkInterfaces} = require("os");
|
||||
const execa = require("execa");
|
||||
|
||||
const gwArgs = "path Win32_NetworkAdapterConfiguration where IPEnabled=true get DefaultIPGateway,GatewayCostMetric,IPConnectionMetric,Index /format:table".split(" ");
|
||||
const ifArgs = index => `path Win32_NetworkAdapter where Index=${index} get NetConnectionID,MACAddress /format:table`.split(" ");
|
||||
|
||||
const spawnOpts = {
|
||||
windowsHide: true,
|
||||
};
|
||||
|
||||
// Parsing tables like this. The final metric is GatewayCostMetric + IPConnectionMetric
|
||||
//
|
||||
// DefaultIPGateway GatewayCostMetric Index IPConnectionMetric
|
||||
// {"1.2.3.4", "2001:db8::1"} {0, 256} 12 25
|
||||
// {"2.3.4.5"} {25} 12 55
|
||||
function parseGwTable(gwTable, family) {
|
||||
let [bestGw, bestMetric, bestId] = [null, null, null];
|
||||
|
||||
for (let line of (gwTable || "").trim().split(/\r?\n/).splice(1)) {
|
||||
line = line.trim();
|
||||
const [_, gwArr, gwCostsArr, id, ipMetric] = /({.+?}) +?({.+?}) +?([0-9]+) +?([0-9]+)/g.exec(line) || [];
|
||||
if (!gwArr) continue;
|
||||
|
||||
const gateways = (gwArr.match(/"(.+?)"/g) || []).map(match => match.substring(1, match.length - 1));
|
||||
const gatewayCosts = (gwCostsArr.match(/[0-9]+/g) || []);
|
||||
|
||||
for (const [index, gateway] of Object.entries(gateways)) {
|
||||
if (!gateway || `v${isIP(gateway)}` !== family) continue;
|
||||
|
||||
const metric = parseInt(gatewayCosts[index]) + parseInt(ipMetric);
|
||||
if (!bestGw || metric < bestMetric) {
|
||||
[bestGw, bestMetric, bestId] = [gateway, metric, id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bestGw) return [bestGw, bestId];
|
||||
}
|
||||
|
||||
function parseIfTable(ifTable) {
|
||||
const line = (ifTable || "").trim().split("\n")[1];
|
||||
|
||||
let [mac, name] = line.trim().split(/\s+/);
|
||||
mac = mac.toLowerCase();
|
||||
|
||||
// try to get the interface name by matching the mac to os.networkInterfaces to avoid wmic's encoding issues
|
||||
// https://github.com/silverwind/default-gateway/issues/14
|
||||
for (const [osname, addrs] of Object.entries(networkInterfaces())) {
|
||||
for (const addr of addrs) {
|
||||
if (addr && addr.mac && addr.mac.toLowerCase() === mac) {
|
||||
return osname;
|
||||
}
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
const promise = async family => {
|
||||
const {stdout} = await execa("wmic", gwArgs, spawnOpts);
|
||||
const [gateway, id] = parseGwTable(stdout, family) || [];
|
||||
|
||||
if (!gateway) {
|
||||
throw new Error("Unable to determine default gateway");
|
||||
}
|
||||
|
||||
let name;
|
||||
if (id) {
|
||||
const {stdout} = await execa("wmic", ifArgs(id), spawnOpts);
|
||||
name = parseIfTable(stdout);
|
||||
}
|
||||
|
||||
return {gateway, interface: name ? name : null};
|
||||
};
|
||||
|
||||
const sync = family => {
|
||||
const {stdout} = execa.sync("wmic", gwArgs, spawnOpts);
|
||||
const [gateway, id] = parseGwTable(stdout, family) || [];
|
||||
|
||||
if (!gateway) {
|
||||
throw new Error("Unable to determine default gateway");
|
||||
}
|
||||
|
||||
let name;
|
||||
if (id) {
|
||||
const {stdout} = execa.sync("wmic", ifArgs(id), spawnOpts);
|
||||
name = parseIfTable(stdout);
|
||||
}
|
||||
|
||||
return {gateway, interface: name ? name : null};
|
||||
};
|
||||
|
||||
module.exports.v4 = () => promise("v4");
|
||||
module.exports.v6 = () => promise("v6");
|
||||
|
||||
module.exports.v4.sync = () => sync("v4");
|
||||
module.exports.v6.sync = () => sync("v6");
|
Loading…
Add table
Add a link
Reference in a new issue