nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions

208
node_modules/execa/index.js generated vendored
View File

@@ -1,6 +1,6 @@
'use strict';
const path = require('path');
const childProcess = require('child_process');
const util = require('util');
const crossSpawn = require('cross-spawn');
const stripEof = require('strip-eof');
const npmRunPath = require('npm-run-path');
@@ -16,18 +16,26 @@ const TEN_MEGABYTES = 1000 * 1000 * 10;
function handleArgs(cmd, args, opts) {
let parsed;
if (opts && opts.env && opts.extendEnv !== false) {
opts = Object.assign({
extendEnv: true,
env: {}
}, opts);
if (opts.extendEnv) {
opts.env = Object.assign({}, process.env, opts.env);
}
if (opts && opts.__winShell === true) {
if (opts.__winShell === true) {
delete opts.__winShell;
parsed = {
command: cmd,
args,
options: opts,
file: cmd,
original: cmd
original: {
cmd,
args
}
};
} else {
parsed = crossSpawn._parse(cmd, args, opts);
@@ -35,6 +43,7 @@ function handleArgs(cmd, args, opts) {
opts = Object.assign({
maxBuffer: TEN_MEGABYTES,
buffer: true,
stripEof: true,
preferLocal: true,
localDir: parsed.options.cwd || process.cwd(),
@@ -49,6 +58,16 @@ function handleArgs(cmd, args, opts) {
opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));
}
if (opts.detached) {
// #115
opts.cleanup = false;
}
if (process.platform === 'win32' && path.basename(parsed.command) === 'cmd.exe') {
// #116
parsed.args.unshift('/q');
}
return {
cmd: parsed.command,
args: parsed.args,
@@ -57,9 +76,7 @@ function handleArgs(cmd, args, opts) {
};
}
function handleInput(spawned, opts) {
const input = opts.input;
function handleInput(spawned, input) {
if (input === null || input === undefined) {
return;
}
@@ -100,14 +117,21 @@ function handleShell(fn, cmd, opts) {
return fn(file, args, opts);
}
function getStream(process, stream, encoding, maxBuffer) {
function getStream(process, stream, {encoding, buffer, maxBuffer}) {
if (!process[stream]) {
return null;
}
let ret;
if (encoding) {
if (!buffer) {
// TODO: Use `ret = util.promisify(stream.finished)(process[stream]);` when targeting Node.js 10
ret = new Promise((resolve, reject) => {
process[stream]
.once('end', resolve)
.once('error', reject);
});
} else if (encoding) {
ret = _getStream(process[stream], {
encoding,
maxBuffer
@@ -123,16 +147,58 @@ function getStream(process, stream, encoding, maxBuffer) {
});
}
module.exports = (cmd, args, opts) => {
function makeError(result, options) {
const {stdout, stderr} = result;
let err = result.error;
const {code, signal} = result;
const {parsed, joinedCmd} = options;
const timedOut = options.timedOut || false;
if (!err) {
let output = '';
if (Array.isArray(parsed.opts.stdio)) {
if (parsed.opts.stdio[2] !== 'inherit') {
output += output.length > 0 ? stderr : `\n${stderr}`;
}
if (parsed.opts.stdio[1] !== 'inherit') {
output += `\n${stdout}`;
}
} else if (parsed.opts.stdio !== 'inherit') {
output = `\n${stderr}${stdout}`;
}
err = new Error(`Command failed: ${joinedCmd}${output}`);
err.code = code < 0 ? errname(code) : code;
}
err.stdout = stdout;
err.stderr = stderr;
err.failed = true;
err.signal = signal || null;
err.cmd = joinedCmd;
err.timedOut = timedOut;
return err;
}
function joinCmd(cmd, args) {
let joinedCmd = cmd;
if (Array.isArray(args) && args.length > 0) {
joinedCmd += ' ' + args.join(' ');
}
return joinedCmd;
}
module.exports = (cmd, args, opts) => {
const parsed = handleArgs(cmd, args, opts);
const encoding = parsed.opts.encoding;
const maxBuffer = parsed.opts.maxBuffer;
const {encoding, buffer, maxBuffer} = parsed.opts;
const joinedCmd = joinCmd(cmd, args);
let spawned;
try {
@@ -151,11 +217,15 @@ module.exports = (cmd, args, opts) => {
let timeoutId = null;
let timedOut = false;
const cleanupTimeout = () => {
const cleanup = () => {
if (timeoutId) {
clearTimeout(timeoutId);
timeoutId = null;
}
if (removeExitHandler) {
removeExitHandler();
}
};
if (parsed.opts.timeout > 0) {
@@ -168,19 +238,19 @@ module.exports = (cmd, args, opts) => {
const processDone = new Promise(resolve => {
spawned.on('exit', (code, signal) => {
cleanupTimeout();
cleanup();
resolve({code, signal});
});
spawned.on('error', err => {
cleanupTimeout();
resolve({err});
cleanup();
resolve({error: err});
});
if (spawned.stdin) {
spawned.stdin.on('error', err => {
cleanupTimeout();
resolve({err});
cleanup();
resolve({error: err});
});
}
});
@@ -195,55 +265,27 @@ module.exports = (cmd, args, opts) => {
}
}
const promise = pFinally(Promise.all([
const handlePromise = () => pFinally(Promise.all([
processDone,
getStream(spawned, 'stdout', encoding, maxBuffer),
getStream(spawned, 'stderr', encoding, maxBuffer)
getStream(spawned, 'stdout', {encoding, buffer, maxBuffer}),
getStream(spawned, 'stderr', {encoding, buffer, maxBuffer})
]).then(arr => {
const result = arr[0];
const stdout = arr[1];
const stderr = arr[2];
result.stdout = arr[1];
result.stderr = arr[2];
let err = result.err;
const code = result.code;
const signal = result.signal;
if (removeExitHandler) {
removeExitHandler();
}
if (err || code !== 0 || signal !== null) {
if (!err) {
let output = '';
if (Array.isArray(parsed.opts.stdio)) {
if (parsed.opts.stdio[2] !== 'inherit') {
output += output.length > 0 ? stderr : `\n${stderr}`;
}
if (parsed.opts.stdio[1] !== 'inherit') {
output += `\n${stdout}`;
}
} else if (parsed.opts.stdio !== 'inherit') {
output = `\n${stderr}${stdout}`;
}
err = new Error(`Command failed: ${joinedCmd}${output}`);
err.code = code < 0 ? errname(code) : code;
}
if (result.error || result.code !== 0 || result.signal !== null) {
const err = makeError(result, {
joinedCmd,
parsed,
timedOut
});
// TODO: missing some timeout logic for killed
// https://github.com/nodejs/node/blob/master/lib/child_process.js#L203
// err.killed = spawned.killed || killed;
err.killed = err.killed || spawned.killed;
err.stdout = stdout;
err.stderr = stderr;
err.failed = true;
err.signal = signal || null;
err.cmd = joinedCmd;
err.timedOut = timedOut;
if (!parsed.opts.reject) {
return err;
}
@@ -252,8 +294,8 @@ module.exports = (cmd, args, opts) => {
}
return {
stdout: handleOutput(parsed.opts, stdout),
stderr: handleOutput(parsed.opts, stderr),
stdout: handleOutput(parsed.opts, result.stdout),
stderr: handleOutput(parsed.opts, result.stderr),
code: 0,
failed: false,
killed: false,
@@ -265,45 +307,55 @@ module.exports = (cmd, args, opts) => {
crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed);
handleInput(spawned, parsed.opts);
handleInput(spawned, parsed.opts.input);
spawned.then = promise.then.bind(promise);
spawned.catch = promise.catch.bind(promise);
spawned.then = (onfulfilled, onrejected) => handlePromise().then(onfulfilled, onrejected);
spawned.catch = onrejected => handlePromise().catch(onrejected);
return spawned;
};
module.exports.stdout = function () {
// TODO: set `stderr: 'ignore'` when that option is implemented
return module.exports.apply(null, arguments).then(x => x.stdout);
};
// TODO: set `stderr: 'ignore'` when that option is implemented
module.exports.stdout = (...args) => module.exports(...args).then(x => x.stdout);
module.exports.stderr = function () {
// TODO: set `stdout: 'ignore'` when that option is implemented
return module.exports.apply(null, arguments).then(x => x.stderr);
};
// TODO: set `stdout: 'ignore'` when that option is implemented
module.exports.stderr = (...args) => module.exports(...args).then(x => x.stderr);
module.exports.shell = (cmd, opts) => handleShell(module.exports, cmd, opts);
module.exports.sync = (cmd, args, opts) => {
const parsed = handleArgs(cmd, args, opts);
const joinedCmd = joinCmd(cmd, args);
if (isStream(parsed.opts.input)) {
throw new TypeError('The `input` option cannot be a stream in sync mode');
}
const result = childProcess.spawnSync(parsed.cmd, parsed.args, parsed.opts);
result.code = result.status;
if (result.error || result.status !== 0) {
throw (result.error || new Error(result.stderr === '' ? result.stdout : result.stderr));
if (result.error || result.status !== 0 || result.signal !== null) {
const err = makeError(result, {
joinedCmd,
parsed
});
if (!parsed.opts.reject) {
return err;
}
throw err;
}
result.stdout = handleOutput(parsed.opts, result.stdout);
result.stderr = handleOutput(parsed.opts, result.stderr);
return result;
return {
stdout: handleOutput(parsed.opts, result.stdout),
stderr: handleOutput(parsed.opts, result.stderr),
code: 0,
failed: false,
signal: null,
cmd: joinedCmd,
timedOut: false
};
};
module.exports.shellSync = (cmd, opts) => handleShell(module.exports.sync, cmd, opts);
module.exports.spawn = util.deprecate(module.exports, 'execa.spawn() is deprecated. Use execa() instead.');