npm-check-updates
Version:
Find newer versions of dependencies than what your package.json allows
1,118 lines • 232 kB
JavaScript
#!/usr/bin/env node
import { a as wr, i as M, n as Br, o as oe, r as Or, t as k } from "./chunks/chunk-Njdj7H0c.js";
import Sr, { a as xr, c as vt, d as Tr, f as ge, i as _t, l as Rr, n as $r, o as Pr, r as Ue, s as Nr, t as Ir, u as ne } from "./index.js";
import Pe from "path";
import kr from "os";
import P, { env as ve } from "node:process";
import xe from "node:os";
import U from "node:path";
import { fileURLToPath as Zt } from "node:url";
import { format as Ge, promisify as X } from "node:util";
import j from "node:fs";
import { spawn as jr } from "node:child_process";
var Ne = /* @__PURE__ */ k(((e) => {
var r = class extends Error {
constructor(l, i, s) {
super(s), Error.captureStackTrace(this, this.constructor), this.name = this.constructor.name, this.code = i, this.exitCode = l, this.nestedError = void 0;
}
}, n = class extends r {
constructor(l) {
super(1, "commander.invalidArgument", l), Error.captureStackTrace(this, this.constructor), this.name = this.constructor.name;
}
};
e.CommanderError = r, e.InvalidArgumentError = n;
})), ft = /* @__PURE__ */ k(((e) => {
var { InvalidArgumentError: r } = Ne(), n = class {
constructor(i, s) {
switch (this.description = s || "", this.variadic = !1, this.parseArg = void 0, this.defaultValue = void 0, this.defaultValueDescription = void 0, this.argChoices = void 0, i[0]) {
case "<":
this.required = !0, this._name = i.slice(1, -1);
break;
case "[":
this.required = !1, this._name = i.slice(1, -1);
break;
default:
this.required = !0, this._name = i;
break;
}
this._name.endsWith("...") && (this.variadic = !0, this._name = this._name.slice(0, -3));
}
name() {
return this._name;
}
_collectValue(i, s) {
return s === this.defaultValue || !Array.isArray(s) ? [i] : (s.push(i), s);
}
default(i, s) {
return this.defaultValue = i, this.defaultValueDescription = s, this;
}
argParser(i) {
return this.parseArg = i, this;
}
choices(i) {
return this.argChoices = i.slice(), this.parseArg = (s, D) => {
if (!this.argChoices.includes(s)) throw new r(`Allowed choices are ${this.argChoices.join(", ")}.`);
return this.variadic ? this._collectValue(s, D) : s;
}, this;
}
argRequired() {
return this.required = !0, this;
}
argOptional() {
return this.required = !1, this;
}
};
function l(i) {
const s = i.name() + (i.variadic === !0 ? "..." : "");
return i.required ? "<" + s + ">" : "[" + s + "]";
}
e.Argument = n, e.humanReadableArgName = l;
})), er = /* @__PURE__ */ k(((e) => {
var { humanReadableArgName: r } = ft(), n = class {
constructor() {
this.helpWidth = void 0, this.minWidthToWrap = 40, this.sortSubcommands = !1, this.sortOptions = !1, this.showGlobalOptions = !1;
}
prepareContext(i) {
this.helpWidth = this.helpWidth ?? i.helpWidth ?? 80;
}
visibleCommands(i) {
const s = i.commands.filter((o) => !o._hidden), D = i._getHelpCommand();
return D && !D._hidden && s.push(D), this.sortSubcommands && s.sort((o, u) => o.name().localeCompare(u.name())), s;
}
compareOptions(i, s) {
const D = (o) => o.short ? o.short.replace(/^-/, "") : o.long.replace(/^--/, "");
return D(i).localeCompare(D(s));
}
visibleOptions(i) {
const s = i.options.filter((o) => !o.hidden), D = i._getHelpOption();
if (D && !D.hidden) {
const o = D.short && i._findOption(D.short), u = D.long && i._findOption(D.long);
!o && !u ? s.push(D) : D.long && !u ? s.push(i.createOption(D.long, D.description)) : D.short && !o && s.push(i.createOption(D.short, D.description));
}
return this.sortOptions && s.sort(this.compareOptions), s;
}
visibleGlobalOptions(i) {
if (!this.showGlobalOptions) return [];
const s = [];
for (let D = i.parent; D; D = D.parent) {
const o = D.options.filter((u) => !u.hidden);
s.push(...o);
}
return this.sortOptions && s.sort(this.compareOptions), s;
}
visibleArguments(i) {
return i._argsDescription && i.registeredArguments.forEach((s) => {
s.description = s.description || i._argsDescription[s.name()] || "";
}), i.registeredArguments.find((s) => s.description) ? i.registeredArguments : [];
}
subcommandTerm(i) {
const s = i.registeredArguments.map((D) => r(D)).join(" ");
return i._name + (i._aliases[0] ? "|" + i._aliases[0] : "") + (i.options.length ? " [options]" : "") + (s ? " " + s : "");
}
optionTerm(i) {
return i.flags;
}
argumentTerm(i) {
return i.name();
}
longestSubcommandTermLength(i, s) {
return s.visibleCommands(i).reduce((D, o) => Math.max(D, this.displayWidth(s.styleSubcommandTerm(s.subcommandTerm(o)))), 0);
}
longestOptionTermLength(i, s) {
return s.visibleOptions(i).reduce((D, o) => Math.max(D, this.displayWidth(s.styleOptionTerm(s.optionTerm(o)))), 0);
}
longestGlobalOptionTermLength(i, s) {
return s.visibleGlobalOptions(i).reduce((D, o) => Math.max(D, this.displayWidth(s.styleOptionTerm(s.optionTerm(o)))), 0);
}
longestArgumentTermLength(i, s) {
return s.visibleArguments(i).reduce((D, o) => Math.max(D, this.displayWidth(s.styleArgumentTerm(s.argumentTerm(o)))), 0);
}
commandUsage(i) {
let s = i._name;
i._aliases[0] && (s = s + "|" + i._aliases[0]);
let D = "";
for (let o = i.parent; o; o = o.parent) D = o.name() + " " + D;
return D + s + " " + i.usage();
}
commandDescription(i) {
return i.description();
}
subcommandDescription(i) {
return i.summary() || i.description();
}
optionDescription(i) {
const s = [];
if (i.argChoices && s.push(`choices: ${i.argChoices.map((D) => JSON.stringify(D)).join(", ")}`), i.defaultValue !== void 0 && (i.required || i.optional || i.isBoolean() && typeof i.defaultValue == "boolean") && s.push(`default: ${i.defaultValueDescription || JSON.stringify(i.defaultValue)}`), i.presetArg !== void 0 && i.optional && s.push(`preset: ${JSON.stringify(i.presetArg)}`), i.envVar !== void 0 && s.push(`env: ${i.envVar}`), s.length > 0) {
const D = `(${s.join(", ")})`;
return i.description ? `${i.description} ${D}` : D;
}
return i.description;
}
argumentDescription(i) {
const s = [];
if (i.argChoices && s.push(`choices: ${i.argChoices.map((D) => JSON.stringify(D)).join(", ")}`), i.defaultValue !== void 0 && s.push(`default: ${i.defaultValueDescription || JSON.stringify(i.defaultValue)}`), s.length > 0) {
const D = `(${s.join(", ")})`;
return i.description ? `${i.description} ${D}` : D;
}
return i.description;
}
formatItemList(i, s, D) {
return s.length === 0 ? [] : [
D.styleTitle(i),
...s,
""
];
}
groupItems(i, s, D) {
const o = /* @__PURE__ */ new Map();
return i.forEach((u) => {
const c = D(u);
o.has(c) || o.set(c, []);
}), s.forEach((u) => {
const c = D(u);
o.has(c) || o.set(c, []), o.get(c).push(u);
}), o;
}
formatHelp(i, s) {
const D = s.padWidth(i, s), o = s.helpWidth ?? 80;
function u(m, g) {
return s.formatItem(m, D, g, s);
}
let c = [`${s.styleTitle("Usage:")} ${s.styleUsage(s.commandUsage(i))}`, ""];
const F = s.commandDescription(i);
F.length > 0 && (c = c.concat([s.boxWrap(s.styleCommandDescription(F), o), ""]));
const h = s.visibleArguments(i).map((m) => u(s.styleArgumentTerm(s.argumentTerm(m)), s.styleArgumentDescription(s.argumentDescription(m))));
if (c = c.concat(this.formatItemList("Arguments:", h, s)), this.groupItems(i.options, s.visibleOptions(i), (m) => m.helpGroupHeading ?? "Options:").forEach((m, g) => {
const E = m.map((v) => u(s.styleOptionTerm(s.optionTerm(v)), s.styleOptionDescription(s.optionDescription(v))));
c = c.concat(this.formatItemList(g, E, s));
}), s.showGlobalOptions) {
const m = s.visibleGlobalOptions(i).map((g) => u(s.styleOptionTerm(s.optionTerm(g)), s.styleOptionDescription(s.optionDescription(g))));
c = c.concat(this.formatItemList("Global Options:", m, s));
}
return this.groupItems(i.commands, s.visibleCommands(i), (m) => m.helpGroup() || "Commands:").forEach((m, g) => {
const E = m.map((v) => u(s.styleSubcommandTerm(s.subcommandTerm(v)), s.styleSubcommandDescription(s.subcommandDescription(v))));
c = c.concat(this.formatItemList(g, E, s));
}), c.join(`
`);
}
displayWidth(i) {
return l(i).length;
}
styleTitle(i) {
return i;
}
styleUsage(i) {
return i.split(" ").map((s) => s === "[options]" ? this.styleOptionText(s) : s === "[command]" ? this.styleSubcommandText(s) : s[0] === "[" || s[0] === "<" ? this.styleArgumentText(s) : this.styleCommandText(s)).join(" ");
}
styleCommandDescription(i) {
return this.styleDescriptionText(i);
}
styleOptionDescription(i) {
return this.styleDescriptionText(i);
}
styleSubcommandDescription(i) {
return this.styleDescriptionText(i);
}
styleArgumentDescription(i) {
return this.styleDescriptionText(i);
}
styleDescriptionText(i) {
return i;
}
styleOptionTerm(i) {
return this.styleOptionText(i);
}
styleSubcommandTerm(i) {
return i.split(" ").map((s) => s === "[options]" ? this.styleOptionText(s) : s[0] === "[" || s[0] === "<" ? this.styleArgumentText(s) : this.styleSubcommandText(s)).join(" ");
}
styleArgumentTerm(i) {
return this.styleArgumentText(i);
}
styleOptionText(i) {
return i;
}
styleArgumentText(i) {
return i;
}
styleSubcommandText(i) {
return i;
}
styleCommandText(i) {
return i;
}
padWidth(i, s) {
return Math.max(s.longestOptionTermLength(i, s), s.longestGlobalOptionTermLength(i, s), s.longestSubcommandTermLength(i, s), s.longestArgumentTermLength(i, s));
}
preformatted(i) {
return /\n[^\S\r\n]/.test(i);
}
formatItem(i, s, D, o) {
const c = " ".repeat(2);
if (!D) return c + i;
const F = i.padEnd(s + i.length - o.displayWidth(i)), h = 2, m = (this.helpWidth ?? 80) - s - h - 2;
let g;
return m < this.minWidthToWrap || o.preformatted(D) ? g = D : g = o.boxWrap(D, m).replace(/\n/g, `
` + " ".repeat(s + h)), c + F + " ".repeat(h) + g.replace(/\n/g, `
${c}`);
}
boxWrap(i, s) {
if (s < this.minWidthToWrap) return i;
const D = i.split(/\r\n|\n/), o = /[\s]*[^\s]+/g, u = [];
return D.forEach((c) => {
const F = c.match(o);
if (F === null) {
u.push("");
return;
}
let h = [F.shift()], m = this.displayWidth(h[0]);
F.forEach((g) => {
const E = this.displayWidth(g);
if (m + E <= s) {
h.push(g), m += E;
return;
}
u.push(h.join(""));
const v = g.trimStart();
h = [v], m = this.displayWidth(v);
}), u.push(h.join(""));
}), u.join(`
`);
}
};
function l(i) {
return i.replace(/\x1b\[\d*(;\d*)*m/g, "");
}
e.Help = n, e.stripColor = l;
})), tr = /* @__PURE__ */ k(((e) => {
var { InvalidArgumentError: r } = Ne(), n = class {
constructor(D, o) {
this.flags = D, this.description = o || "", this.required = D.includes("<"), this.optional = D.includes("["), this.variadic = /\w\.\.\.[>\]]$/.test(D), this.mandatory = !1;
const u = s(D);
this.short = u.shortFlag, this.long = u.longFlag, this.negate = !1, this.long && (this.negate = this.long.startsWith("--no-")), this.defaultValue = void 0, this.defaultValueDescription = void 0, this.presetArg = void 0, this.envVar = void 0, this.parseArg = void 0, this.hidden = !1, this.argChoices = void 0, this.conflictsWith = [], this.implied = void 0, this.helpGroupHeading = void 0;
}
default(D, o) {
return this.defaultValue = D, this.defaultValueDescription = o, this;
}
preset(D) {
return this.presetArg = D, this;
}
conflicts(D) {
return this.conflictsWith = this.conflictsWith.concat(D), this;
}
implies(D) {
let o = D;
return typeof D == "string" && (o = { [D]: !0 }), this.implied = Object.assign(this.implied || {}, o), this;
}
env(D) {
return this.envVar = D, this;
}
argParser(D) {
return this.parseArg = D, this;
}
makeOptionMandatory(D = !0) {
return this.mandatory = !!D, this;
}
hideHelp(D = !0) {
return this.hidden = !!D, this;
}
_collectValue(D, o) {
return o === this.defaultValue || !Array.isArray(o) ? [D] : (o.push(D), o);
}
choices(D) {
return this.argChoices = D.slice(), this.parseArg = (o, u) => {
if (!this.argChoices.includes(o)) throw new r(`Allowed choices are ${this.argChoices.join(", ")}.`);
return this.variadic ? this._collectValue(o, u) : o;
}, this;
}
name() {
return this.long ? this.long.replace(/^--/, "") : this.short.replace(/^-/, "");
}
attributeName() {
return this.negate ? i(this.name().replace(/^no-/, "")) : i(this.name());
}
helpGroup(D) {
return this.helpGroupHeading = D, this;
}
is(D) {
return this.short === D || this.long === D;
}
isBoolean() {
return !this.required && !this.optional && !this.negate;
}
}, l = class {
constructor(D) {
this.positiveOptions = /* @__PURE__ */ new Map(), this.negativeOptions = /* @__PURE__ */ new Map(), this.dualOptions = /* @__PURE__ */ new Set(), D.forEach((o) => {
o.negate ? this.negativeOptions.set(o.attributeName(), o) : this.positiveOptions.set(o.attributeName(), o);
}), this.negativeOptions.forEach((o, u) => {
this.positiveOptions.has(u) && this.dualOptions.add(u);
});
}
valueFromOption(D, o) {
const u = o.attributeName();
if (!this.dualOptions.has(u)) return !0;
const c = this.negativeOptions.get(u).presetArg, F = c !== void 0 ? c : !1;
return o.negate === (F === D);
}
};
function i(D) {
return D.split("-").reduce((o, u) => o + u[0].toUpperCase() + u.slice(1));
}
function s(D) {
let o, u;
const c = /^-[^-]$/, F = /^--[^-]/, h = D.split(/[ |,]+/).concat("guard");
if (c.test(h[0]) && (o = h.shift()), F.test(h[0]) && (u = h.shift()), !o && c.test(h[0]) && (o = h.shift()), !o && F.test(h[0]) && (o = u, u = h.shift()), h[0].startsWith("-")) {
const m = h[0], g = `option creation failed due to '${m}' in option flags '${D}'`;
throw /^-[^-][^-]/.test(m) ? new Error(`${g}
- a short flag is a single dash and a single character
- either use a single dash and a single character (for a short flag)
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`) : c.test(m) ? new Error(`${g}
- too many short flags`) : F.test(m) ? new Error(`${g}
- too many long flags`) : new Error(`${g}
- unrecognised flag format`);
}
if (o === void 0 && u === void 0) throw new Error(`option creation failed due to no flags found in '${D}'.`);
return {
shortFlag: o,
longFlag: u
};
}
e.Option = n, e.DualOptions = l;
})), Lr = /* @__PURE__ */ k(((e) => {
var r = 3;
function n(i, s) {
if (Math.abs(i.length - s.length) > r) return Math.max(i.length, s.length);
const D = [];
for (let o = 0; o <= i.length; o++) D[o] = [o];
for (let o = 0; o <= s.length; o++) D[0][o] = o;
for (let o = 1; o <= s.length; o++) for (let u = 1; u <= i.length; u++) {
let c = 1;
i[u - 1] === s[o - 1] ? c = 0 : c = 1, D[u][o] = Math.min(D[u - 1][o] + 1, D[u][o - 1] + 1, D[u - 1][o - 1] + c), u > 1 && o > 1 && i[u - 1] === s[o - 2] && i[u - 2] === s[o - 1] && (D[u][o] = Math.min(D[u][o], D[u - 2][o - 2] + 1));
}
return D[i.length][s.length];
}
function l(i, s) {
if (!s || s.length === 0) return "";
s = Array.from(new Set(s));
const D = i.startsWith("--");
D && (i = i.slice(2), s = s.map((F) => F.slice(2)));
let o = [], u = r;
const c = 0.4;
return s.forEach((F) => {
if (F.length <= 1) return;
const h = n(i, F), m = Math.max(i.length, F.length);
(m - h) / m > c && (h < u ? (u = h, o = [F]) : h === u && o.push(F));
}), o.sort((F, h) => F.localeCompare(h)), D && (o = o.map((F) => `--${F}`)), o.length > 1 ? `
(Did you mean one of ${o.join(", ")}?)` : o.length === 1 ? `
(Did you mean ${o[0]}?)` : "";
}
e.suggestSimilar = l;
})), Mr = /* @__PURE__ */ k(((e) => {
var r = M("node:events").EventEmitter, n = M("node:child_process"), l = M("node:path"), i = M("node:fs"), s = M("node:process"), { Argument: D, humanReadableArgName: o } = ft(), { CommanderError: u } = Ne(), { Help: c, stripColor: F } = er(), { Option: h, DualOptions: m } = tr(), { suggestSimilar: g } = Lr(), E = class rr extends r {
constructor(t) {
super(), this.commands = [], this.options = [], this.parent = null, this._allowUnknownOption = !1, this._allowExcessArguments = !1, this.registeredArguments = [], this._args = this.registeredArguments, this.args = [], this.rawArgs = [], this.processedArgs = [], this._scriptPath = null, this._name = t || "", this._optionValues = {}, this._optionValueSources = {}, this._storeOptionsAsProperties = !1, this._actionHandler = null, this._executableHandler = !1, this._executableFile = null, this._executableDir = null, this._defaultCommandName = null, this._exitCallback = null, this._aliases = [], this._combineFlagAndOptionalValue = !0, this._description = "", this._summary = "", this._argsDescription = void 0, this._enablePositionalOptions = !1, this._passThroughOptions = !1, this._lifeCycleHooks = {}, this._showHelpAfterError = !1, this._showSuggestionAfterError = !0, this._savedState = null, this._outputConfiguration = {
writeOut: (a) => s.stdout.write(a),
writeErr: (a) => s.stderr.write(a),
outputError: (a, p) => p(a),
getOutHelpWidth: () => s.stdout.isTTY ? s.stdout.columns : void 0,
getErrHelpWidth: () => s.stderr.isTTY ? s.stderr.columns : void 0,
getOutHasColors: () => y() ?? (s.stdout.isTTY && s.stdout.hasColors?.()),
getErrHasColors: () => y() ?? (s.stderr.isTTY && s.stderr.hasColors?.()),
stripColor: (a) => F(a)
}, this._hidden = !1, this._helpOption = void 0, this._addImplicitHelpCommand = void 0, this._helpCommand = void 0, this._helpConfiguration = {}, this._helpGroupHeading = void 0, this._defaultCommandGroup = void 0, this._defaultOptionGroup = void 0;
}
copyInheritedSettings(t) {
return this._outputConfiguration = t._outputConfiguration, this._helpOption = t._helpOption, this._helpCommand = t._helpCommand, this._helpConfiguration = t._helpConfiguration, this._exitCallback = t._exitCallback, this._storeOptionsAsProperties = t._storeOptionsAsProperties, this._combineFlagAndOptionalValue = t._combineFlagAndOptionalValue, this._allowExcessArguments = t._allowExcessArguments, this._enablePositionalOptions = t._enablePositionalOptions, this._showHelpAfterError = t._showHelpAfterError, this._showSuggestionAfterError = t._showSuggestionAfterError, this;
}
_getCommandAndAncestors() {
const t = [];
for (let a = this; a; a = a.parent) t.push(a);
return t;
}
command(t, a, p) {
let d = a, C = p;
typeof d == "object" && d !== null && (C = d, d = null), C = C || {};
const [, _, A] = t.match(/([^ ]+) *(.*)/), b = this.createCommand(_);
return d && (b.description(d), b._executableHandler = !0), C.isDefault && (this._defaultCommandName = b._name), b._hidden = !!(C.noHelp || C.hidden), b._executableFile = C.executableFile || null, A && b.arguments(A), this._registerCommand(b), b.parent = this, b.copyInheritedSettings(this), d ? this : b;
}
createCommand(t) {
return new rr(t);
}
createHelp() {
return Object.assign(new c(), this.configureHelp());
}
configureHelp(t) {
return t === void 0 ? this._helpConfiguration : (this._helpConfiguration = t, this);
}
configureOutput(t) {
return t === void 0 ? this._outputConfiguration : (this._outputConfiguration = {
...this._outputConfiguration,
...t
}, this);
}
showHelpAfterError(t = !0) {
return typeof t != "string" && (t = !!t), this._showHelpAfterError = t, this;
}
showSuggestionAfterError(t = !0) {
return this._showSuggestionAfterError = !!t, this;
}
addCommand(t, a) {
if (!t._name) throw new Error(`Command passed to .addCommand() must have a name
- specify the name in Command constructor or using .name()`);
return a = a || {}, a.isDefault && (this._defaultCommandName = t._name), (a.noHelp || a.hidden) && (t._hidden = !0), this._registerCommand(t), t.parent = this, t._checkForBrokenPassThrough(), this;
}
createArgument(t, a) {
return new D(t, a);
}
argument(t, a, p, d) {
const C = this.createArgument(t, a);
return typeof p == "function" ? C.default(d).argParser(p) : C.default(p), this.addArgument(C), this;
}
arguments(t) {
return t.trim().split(/ +/).forEach((a) => {
this.argument(a);
}), this;
}
addArgument(t) {
const a = this.registeredArguments.slice(-1)[0];
if (a?.variadic) throw new Error(`only the last argument can be variadic '${a.name()}'`);
if (t.required && t.defaultValue !== void 0 && t.parseArg === void 0) throw new Error(`a default value for a required argument is never used: '${t.name()}'`);
return this.registeredArguments.push(t), this;
}
helpCommand(t, a) {
if (typeof t == "boolean")
return this._addImplicitHelpCommand = t, t && this._defaultCommandGroup && this._initCommandGroup(this._getHelpCommand()), this;
const [, p, d] = (t ?? "help [command]").match(/([^ ]+) *(.*)/), C = a ?? "display help for command", _ = this.createCommand(p);
return _.helpOption(!1), d && _.arguments(d), C && _.description(C), this._addImplicitHelpCommand = !0, this._helpCommand = _, (t || a) && this._initCommandGroup(_), this;
}
addHelpCommand(t, a) {
return typeof t != "object" ? (this.helpCommand(t, a), this) : (this._addImplicitHelpCommand = !0, this._helpCommand = t, this._initCommandGroup(t), this);
}
_getHelpCommand() {
return this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help")) ? (this._helpCommand === void 0 && this.helpCommand(void 0, void 0), this._helpCommand) : null;
}
hook(t, a) {
const p = [
"preSubcommand",
"preAction",
"postAction"
];
if (!p.includes(t)) throw new Error(`Unexpected value for event passed to hook : '${t}'.
Expecting one of '${p.join("', '")}'`);
return this._lifeCycleHooks[t] ? this._lifeCycleHooks[t].push(a) : this._lifeCycleHooks[t] = [a], this;
}
exitOverride(t) {
return t ? this._exitCallback = t : this._exitCallback = (a) => {
if (a.code !== "commander.executeSubCommandAsync") throw a;
}, this;
}
_exit(t, a, p) {
this._exitCallback && this._exitCallback(new u(t, a, p)), s.exit(t);
}
action(t) {
const a = (p) => {
const d = this.registeredArguments.length, C = p.slice(0, d);
return this._storeOptionsAsProperties ? C[d] = this : C[d] = this.opts(), C.push(this), t.apply(this, C);
};
return this._actionHandler = a, this;
}
createOption(t, a) {
return new h(t, a);
}
_callParseArg(t, a, p, d) {
try {
return t.parseArg(a, p);
} catch (C) {
if (C.code === "commander.invalidArgument") {
const _ = `${d} ${C.message}`;
this.error(_, {
exitCode: C.exitCode,
code: C.code
});
}
throw C;
}
}
_registerOption(t) {
const a = t.short && this._findOption(t.short) || t.long && this._findOption(t.long);
if (a) {
const p = t.long && this._findOption(t.long) ? t.long : t.short;
throw new Error(`Cannot add option '${t.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${p}'
- already used by option '${a.flags}'`);
}
this._initOptionGroup(t), this.options.push(t);
}
_registerCommand(t) {
const a = (d) => [d.name()].concat(d.aliases()), p = a(t).find((d) => this._findCommand(d));
if (p) {
const d = a(this._findCommand(p)).join("|"), C = a(t).join("|");
throw new Error(`cannot add command '${C}' as already have command '${d}'`);
}
this._initCommandGroup(t), this.commands.push(t);
}
addOption(t) {
this._registerOption(t);
const a = t.name(), p = t.attributeName();
if (t.negate) {
const C = t.long.replace(/^--no-/, "--");
this._findOption(C) || this.setOptionValueWithSource(p, t.defaultValue === void 0 ? !0 : t.defaultValue, "default");
} else t.defaultValue !== void 0 && this.setOptionValueWithSource(p, t.defaultValue, "default");
const d = (C, _, A) => {
C == null && t.presetArg !== void 0 && (C = t.presetArg);
const b = this.getOptionValue(p);
C !== null && t.parseArg ? C = this._callParseArg(t, C, b, _) : C !== null && t.variadic && (C = t._collectValue(C, b)), C == null && (t.negate ? C = !1 : t.isBoolean() || t.optional ? C = !0 : C = ""), this.setOptionValueWithSource(p, C, A);
};
return this.on("option:" + a, (C) => {
d(C, `error: option '${t.flags}' argument '${C}' is invalid.`, "cli");
}), t.envVar && this.on("optionEnv:" + a, (C) => {
d(C, `error: option '${t.flags}' value '${C}' from env '${t.envVar}' is invalid.`, "env");
}), this;
}
_optionEx(t, a, p, d, C) {
if (typeof a == "object" && a instanceof h) throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
const _ = this.createOption(a, p);
if (_.makeOptionMandatory(!!t.mandatory), typeof d == "function") _.default(C).argParser(d);
else if (d instanceof RegExp) {
const A = d;
d = (b, O) => {
const B = A.exec(b);
return B ? B[0] : O;
}, _.default(C).argParser(d);
} else _.default(d);
return this.addOption(_);
}
option(t, a, p, d) {
return this._optionEx({}, t, a, p, d);
}
requiredOption(t, a, p, d) {
return this._optionEx({ mandatory: !0 }, t, a, p, d);
}
combineFlagAndOptionalValue(t = !0) {
return this._combineFlagAndOptionalValue = !!t, this;
}
allowUnknownOption(t = !0) {
return this._allowUnknownOption = !!t, this;
}
allowExcessArguments(t = !0) {
return this._allowExcessArguments = !!t, this;
}
enablePositionalOptions(t = !0) {
return this._enablePositionalOptions = !!t, this;
}
passThroughOptions(t = !0) {
return this._passThroughOptions = !!t, this._checkForBrokenPassThrough(), this;
}
_checkForBrokenPassThrough() {
if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
}
storeOptionsAsProperties(t = !0) {
if (this.options.length) throw new Error("call .storeOptionsAsProperties() before adding options");
if (Object.keys(this._optionValues).length) throw new Error("call .storeOptionsAsProperties() before setting option values");
return this._storeOptionsAsProperties = !!t, this;
}
getOptionValue(t) {
return this._storeOptionsAsProperties ? this[t] : this._optionValues[t];
}
setOptionValue(t, a) {
return this.setOptionValueWithSource(t, a, void 0);
}
setOptionValueWithSource(t, a, p) {
return this._storeOptionsAsProperties ? this[t] = a : this._optionValues[t] = a, this._optionValueSources[t] = p, this;
}
getOptionValueSource(t) {
return this._optionValueSources[t];
}
getOptionValueSourceWithGlobals(t) {
let a;
return this._getCommandAndAncestors().forEach((p) => {
p.getOptionValueSource(t) !== void 0 && (a = p.getOptionValueSource(t));
}), a;
}
_prepareUserArgs(t, a) {
if (t !== void 0 && !Array.isArray(t)) throw new Error("first parameter to parse must be array or undefined");
if (a = a || {}, t === void 0 && a.from === void 0) {
s.versions?.electron && (a.from = "electron");
const d = s.execArgv ?? [];
(d.includes("-e") || d.includes("--eval") || d.includes("-p") || d.includes("--print")) && (a.from = "eval");
}
t === void 0 && (t = s.argv), this.rawArgs = t.slice();
let p;
switch (a.from) {
case void 0:
case "node":
this._scriptPath = t[1], p = t.slice(2);
break;
case "electron":
s.defaultApp ? (this._scriptPath = t[1], p = t.slice(2)) : p = t.slice(1);
break;
case "user":
p = t.slice(0);
break;
case "eval":
p = t.slice(1);
break;
default:
throw new Error(`unexpected parse option { from: '${a.from}' }`);
}
return !this._name && this._scriptPath && this.nameFromFilename(this._scriptPath), this._name = this._name || "program", p;
}
parse(t, a) {
this._prepareForParse();
const p = this._prepareUserArgs(t, a);
return this._parseCommand([], p), this;
}
async parseAsync(t, a) {
this._prepareForParse();
const p = this._prepareUserArgs(t, a);
return await this._parseCommand([], p), this;
}
_prepareForParse() {
this._savedState === null ? this.saveStateBeforeParse() : this.restoreStateBeforeParse();
}
saveStateBeforeParse() {
this._savedState = {
_name: this._name,
_optionValues: { ...this._optionValues },
_optionValueSources: { ...this._optionValueSources }
};
}
restoreStateBeforeParse() {
if (this._storeOptionsAsProperties) throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
- either make a new Command for each call to parse, or stop storing options as properties`);
this._name = this._savedState._name, this._scriptPath = null, this.rawArgs = [], this._optionValues = { ...this._savedState._optionValues }, this._optionValueSources = { ...this._savedState._optionValueSources }, this.args = [], this.processedArgs = [];
}
_checkForMissingExecutable(t, a, p) {
if (i.existsSync(t)) return;
const d = `'${t}' does not exist
- if '${p}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
- ${a ? `searched for local subcommand relative to directory '${a}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`;
throw new Error(d);
}
_executeSubCommand(t, a) {
a = a.slice();
let p = !1;
const d = [
".js",
".ts",
".tsx",
".mjs",
".cjs"
];
function C(B, S) {
const q = l.resolve(B, S);
if (i.existsSync(q)) return q;
if (d.includes(l.extname(S))) return;
const Y = d.find((J) => i.existsSync(`${q}${J}`));
if (Y) return `${q}${Y}`;
}
this._checkForMissingMandatoryOptions(), this._checkForConflictingOptions();
let _ = t._executableFile || `${this._name}-${t._name}`, A = this._executableDir || "";
if (this._scriptPath) {
let B;
try {
B = i.realpathSync(this._scriptPath);
} catch {
B = this._scriptPath;
}
A = l.resolve(l.dirname(B), A);
}
if (A) {
let B = C(A, _);
if (!B && !t._executableFile && this._scriptPath) {
const S = l.basename(this._scriptPath, l.extname(this._scriptPath));
S !== this._name && (B = C(A, `${S}-${t._name}`));
}
_ = B || _;
}
p = d.includes(l.extname(_));
let b;
s.platform !== "win32" ? p ? (a.unshift(_), a = v(s.execArgv).concat(a), b = n.spawn(s.argv[0], a, { stdio: "inherit" })) : b = n.spawn(_, a, { stdio: "inherit" }) : (this._checkForMissingExecutable(_, A, t._name), a.unshift(_), a = v(s.execArgv).concat(a), b = n.spawn(s.execPath, a, { stdio: "inherit" })), b.killed || [
"SIGUSR1",
"SIGUSR2",
"SIGTERM",
"SIGINT",
"SIGHUP"
].forEach((B) => {
s.on(B, () => {
b.killed === !1 && b.exitCode === null && b.kill(B);
});
});
const O = this._exitCallback;
b.on("close", (B) => {
B = B ?? 1, O ? O(new u(B, "commander.executeSubCommandAsync", "(close)")) : s.exit(B);
}), b.on("error", (B) => {
if (B.code === "ENOENT") this._checkForMissingExecutable(_, A, t._name);
else if (B.code === "EACCES") throw new Error(`'${_}' not executable`);
if (!O) s.exit(1);
else {
const S = new u(1, "commander.executeSubCommandAsync", "(error)");
S.nestedError = B, O(S);
}
}), this.runningCommand = b;
}
_dispatchSubcommand(t, a, p) {
const d = this._findCommand(t);
d || this.help({ error: !0 }), d._prepareForParse();
let C;
return C = this._chainOrCallSubCommandHook(C, d, "preSubcommand"), C = this._chainOrCall(C, () => {
if (d._executableHandler) this._executeSubCommand(d, a.concat(p));
else return d._parseCommand(a, p);
}), C;
}
_dispatchHelpCommand(t) {
t || this.help();
const a = this._findCommand(t);
return a && !a._executableHandler && a.help(), this._dispatchSubcommand(t, [], [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]);
}
_checkNumberOfArguments() {
this.registeredArguments.forEach((t, a) => {
t.required && this.args[a] == null && this.missingArgument(t.name());
}), !(this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) && this.args.length > this.registeredArguments.length && this._excessArguments(this.args);
}
_processArguments() {
const t = (p, d, C) => {
let _ = d;
if (d !== null && p.parseArg) {
const A = `error: command-argument value '${d}' is invalid for argument '${p.name()}'.`;
_ = this._callParseArg(p, d, C, A);
}
return _;
};
this._checkNumberOfArguments();
const a = [];
this.registeredArguments.forEach((p, d) => {
let C = p.defaultValue;
p.variadic ? d < this.args.length ? (C = this.args.slice(d), p.parseArg && (C = C.reduce((_, A) => t(p, A, _), p.defaultValue))) : C === void 0 && (C = []) : d < this.args.length && (C = this.args[d], p.parseArg && (C = t(p, C, p.defaultValue))), a[d] = C;
}), this.processedArgs = a;
}
_chainOrCall(t, a) {
return t?.then && typeof t.then == "function" ? t.then(() => a()) : a();
}
_chainOrCallHooks(t, a) {
let p = t;
const d = [];
return this._getCommandAndAncestors().reverse().filter((C) => C._lifeCycleHooks[a] !== void 0).forEach((C) => {
C._lifeCycleHooks[a].forEach((_) => {
d.push({
hookedCommand: C,
callback: _
});
});
}), a === "postAction" && d.reverse(), d.forEach((C) => {
p = this._chainOrCall(p, () => C.callback(C.hookedCommand, this));
}), p;
}
_chainOrCallSubCommandHook(t, a, p) {
let d = t;
return this._lifeCycleHooks[p] !== void 0 && this._lifeCycleHooks[p].forEach((C) => {
d = this._chainOrCall(d, () => C(this, a));
}), d;
}
_parseCommand(t, a) {
const p = this.parseOptions(a);
if (this._parseOptionsEnv(), this._parseOptionsImplied(), t = t.concat(p.operands), a = p.unknown, this.args = t.concat(a), t && this._findCommand(t[0])) return this._dispatchSubcommand(t[0], t.slice(1), a);
if (this._getHelpCommand() && t[0] === this._getHelpCommand().name()) return this._dispatchHelpCommand(t[1]);
if (this._defaultCommandName)
return this._outputHelpIfRequested(a), this._dispatchSubcommand(this._defaultCommandName, t, a);
this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName && this.help({ error: !0 }), this._outputHelpIfRequested(p.unknown), this._checkForMissingMandatoryOptions(), this._checkForConflictingOptions();
const d = () => {
p.unknown.length > 0 && this.unknownOption(p.unknown[0]);
}, C = `command:${this.name()}`;
if (this._actionHandler) {
d(), this._processArguments();
let _;
return _ = this._chainOrCallHooks(_, "preAction"), _ = this._chainOrCall(_, () => this._actionHandler(this.processedArgs)), this.parent && (_ = this._chainOrCall(_, () => {
this.parent.emit(C, t, a);
})), _ = this._chainOrCallHooks(_, "postAction"), _;
}
if (this.parent?.listenerCount(C))
d(), this._processArguments(), this.parent.emit(C, t, a);
else if (t.length) {
if (this._findCommand("*")) return this._dispatchSubcommand("*", t, a);
this.listenerCount("command:*") ? this.emit("command:*", t, a) : this.commands.length ? this.unknownCommand() : (d(), this._processArguments());
} else this.commands.length ? (d(), this.help({ error: !0 })) : (d(), this._processArguments());
}
_findCommand(t) {
if (t)
return this.commands.find((a) => a._name === t || a._aliases.includes(t));
}
_findOption(t) {
return this.options.find((a) => a.is(t));
}
_checkForMissingMandatoryOptions() {
this._getCommandAndAncestors().forEach((t) => {
t.options.forEach((a) => {
a.mandatory && t.getOptionValue(a.attributeName()) === void 0 && t.missingMandatoryOptionValue(a);
});
});
}
_checkForConflictingLocalOptions() {
const t = this.options.filter((a) => {
const p = a.attributeName();
return this.getOptionValue(p) === void 0 ? !1 : this.getOptionValueSource(p) !== "default";
});
t.filter((a) => a.conflictsWith.length > 0).forEach((a) => {
const p = t.find((d) => a.conflictsWith.includes(d.attributeName()));
p && this._conflictingOption(a, p);
});
}
_checkForConflictingOptions() {
this._getCommandAndAncestors().forEach((t) => {
t._checkForConflictingLocalOptions();
});
}
parseOptions(t) {
const a = [], p = [];
let d = a;
function C(B) {
return B.length > 1 && B[0] === "-";
}
const _ = (B) => /^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(B) ? !this._getCommandAndAncestors().some((S) => S.options.map((q) => q.short).some((q) => /^-\d$/.test(q))) : !1;
let A = null, b = null, O = 0;
for (; O < t.length || b; ) {
const B = b ?? t[O++];
if (b = null, B === "--") {
d === p && d.push(B), d.push(...t.slice(O));
break;
}
if (A && (!C(B) || _(B))) {
this.emit(`option:${A.name()}`, B);
continue;
}
if (A = null, C(B)) {
const S = this._findOption(B);
if (S) {
if (S.required) {
const q = t[O++];
q === void 0 && this.optionMissingArgument(S), this.emit(`option:${S.name()}`, q);
} else if (S.optional) {
let q = null;
O < t.length && (!C(t[O]) || _(t[O])) && (q = t[O++]), this.emit(`option:${S.name()}`, q);
} else this.emit(`option:${S.name()}`);
A = S.variadic ? S : null;
continue;
}
}
if (B.length > 2 && B[0] === "-" && B[1] !== "-") {
const S = this._findOption(`-${B[1]}`);
if (S) {
S.required || S.optional && this._combineFlagAndOptionalValue ? this.emit(`option:${S.name()}`, B.slice(2)) : (this.emit(`option:${S.name()}`), b = `-${B.slice(2)}`);
continue;
}
}
if (/^--[^=]+=/.test(B)) {
const S = B.indexOf("="), q = this._findOption(B.slice(0, S));
if (q && (q.required || q.optional)) {
this.emit(`option:${q.name()}`, B.slice(S + 1));
continue;
}
}
if (d === a && C(B) && !(this.commands.length === 0 && _(B)) && (d = p), (this._enablePositionalOptions || this._passThroughOptions) && a.length === 0 && p.length === 0) {
if (this._findCommand(B)) {
a.push(B), p.push(...t.slice(O));
break;
} else if (this._getHelpCommand() && B === this._getHelpCommand().name()) {
a.push(B, ...t.slice(O));
break;
} else if (this._defaultCommandName) {
p.push(B, ...t.slice(O));
break;
}
}
if (this._passThroughOptions) {
d.push(B, ...t.slice(O));
break;
}
d.push(B);
}
return {
operands: a,
unknown: p
};
}
opts() {
if (this._storeOptionsAsProperties) {
const t = {}, a = this.options.length;
for (let p = 0; p < a; p++) {
const d = this.options[p].attributeName();
t[d] = d === this._versionOptionName ? this._version : this[d];
}
return t;
}
return this._optionValues;
}
optsWithGlobals() {
return this._getCommandAndAncestors().reduce((t, a) => Object.assign(t, a.opts()), {});
}
error(t, a) {
this._outputConfiguration.outputError(`${t}
`, this._outputConfiguration.writeErr), typeof this._showHelpAfterError == "string" ? this._outputConfiguration.writeErr(`${this._showHelpAfterError}
`) : this._showHelpAfterError && (this._outputConfiguration.writeErr(`
`), this.outputHelp({ error: !0 }));
const p = a || {}, d = p.exitCode || 1, C = p.code || "commander.error";
this._exit(d, C, t);
}
_parseOptionsEnv() {
this.options.forEach((t) => {
if (t.envVar && t.envVar in s.env) {
const a = t.attributeName();
(this.getOptionValue(a) === void 0 || [
"default",
"config",
"env"
].includes(this.getOptionValueSource(a))) && (t.required || t.optional ? this.emit(`optionEnv:${t.name()}`, s.env[t.envVar]) : this.emit(`optionEnv:${t.name()}`));
}
});
}
_parseOptionsImplied() {
const t = new m(this.options), a = (p) => this.getOptionValue(p) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(p));
this.options.filter((p) => p.implied !== void 0 && a(p.attributeName()) && t.valueFromOption(this.getOptionValue(p.attributeName()), p)).forEach((p) => {
Object.keys(p.implied).filter((d) => !a(d)).forEach((d) => {
this.setOptionValueWithSource(d, p.implied[d], "implied");
});
});
}
missingArgument(t) {
const a = `error: missing required argument '${t}'`;
this.error(a, { code: "commander.missingArgument" });
}
optionMissingArgument(t) {
const a = `error: option '${t.flags}' argument missing`;
this.error(a, { code: "commander.optionMissingArgument" });
}
missingMandatoryOptionValue(t) {
const a = `error: required option '${t.flags}' not specified`;
this.error(a, { code: "commander.missingMandatoryOptionValue" });
}
_conflictingOption(t, a) {
const p = (_) => {
const A = _.attributeName(), b = this.getOptionValue(A), O = this.options.find((S) => S.negate && A === S.attributeName()), B = this.options.find((S) => !S.negate && A === S.attributeName());
return O && (O.presetArg === void 0 && b === !1 || O.presetArg !== void 0 && b === O.presetArg) ? O : B || _;
}, d = (_) => {
const A = p(_), b = A.attributeName();
return this.getOptionValueSource(b) === "env" ? `environment variable '${A.envVar}'` : `option '${A.flags}'`;
}, C = `error: ${d(t)} cannot be used with ${d(a)}`;
this.error(C, { code: "commander.conflictingOption" });
}
unknownOption(t) {
if (this._allowUnknownOption) return;
let a = "";
if (t.startsWith("--") && this._showSuggestionAfterError) {
let d = [], C = this;
do {
const _ = C.createHelp().visibleOptions(C).filter((A) => A.long).map((A) => A.long);
d = d.concat(_), C = C.parent;
} while (C && !C._enablePositionalOptions);
a = g(t, d);
}
const p = `error: unknown option '${t}'${a}`;
this.error(p, { code: "commander.unknownOption" });
}
_excessArguments(t) {
if (this._allowExcessArguments) return;
const a = this.registeredArguments.length, p = a === 1 ? "" : "s", d = `error: too many arguments${this.parent ? ` for '${this.name()}'` : ""}. Expected ${a} argument${p} but got ${t.length}.`;
this.error(d, { code: "commander.excessArguments" });
}
unknownCommand() {
const t = this.args[0];
let a = "";
if (this._showSuggestionAfterError) {
const d = [];
this.createHelp().visibleCommands(this).forEach((C) => {
d.push(C.name()), C.alias() && d.push(C.alias());
}), a = g(t, d);
}
const p = `error: unknown command '${t}'${a}`;
this.error(p, { code: "commander.unknownCommand" });
}
version(t, a, p) {
if (t === void 0) return this._version;
this._version = t, a = a || "-V, --version", p = p || "output the version number";
const d = this.createOption(a, p);
return this._versionOptionName = d.attributeName(), this._registerOption(d), this.on("option:" + d.name(), () => {
this._outputConfiguration.writeOut(`${t}
`), this._exit(0, "commander.version", t);
}), this;
}
description(t, a) {
return t === void 0 && a === void 0 ? this._description : (this._description = t, a && (this._argsDescription = a), this);
}
summary(t) {
return t === void 0 ? this._summary : (this._summary = t, this);
}
alias(t) {
if (t === void 0) return this._aliases[0];
let a = this;
if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler && (a = this.commands[this.commands.length - 1]), t === a._name) throw new Error("Command alias can't be the same as its name");
const p = this.parent?._findCommand(t);
if (p) {
const d = [p.name()].concat(p.aliases()).join("|");
throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${d}'`);
}
return a._aliases.push(t), this;
}
aliases(t) {
return t === void 0 ? this._aliases : (t.forEach((a) => this.alias(a)), this);
}
usage(t) {
if (t === void 0) {
if (this._usage) return this._usage;
const a = this.registeredArguments.map((p) => o(p));
return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? a : []).join(" ");
}
return this._usage = t, this;
}
name(t) {
return t === void 0 ? this._name : (this._name = t, this);
}
helpGroup(t) {
return t === void 0 ? this._helpGroupHeading ?? "" : (this._helpGroupHeading = t, this);
}
commandsGroup(t) {
return t === void 0 ? this._defaultCommandGroup ?? "" : (this._defaultCommandGroup = t, this);
}
optionsGroup(t) {
return t === void 0 ? this._defaultOptionGroup ?? "" : (this._defaultOptionGroup = t, this);
}
_initOptionGroup(t) {
this._defaultOptionGroup && !t.helpGroupHeading && t.helpGroup(this._defaultOptionGroup);
}
_initCommandGroup(t) {
this._defaultCommandGroup && !t.helpGroup() && t.helpGroup(this._defaultCommandGroup);
}
nameFromFilename(t) {
return this._name = l.basename(t, l.extname(t)), this;
}
executableDir(t) {
return t === void 0 ? this._executableDir : (this._executableDir = t, this);
}
helpInformation(t) {
const a = this.createHelp(), p = this._getOutputContext(t);
a.prepareContext({
error: p.error,
helpWidth: p.helpWidth,
outputHasColors: p.hasColors
});
const d = a.formatHelp(this, a);
return p.hasColors ? d : this._outputConfiguration.stripColor(d);
}
_getOutputContext(t) {
t = t || {};
const a = !!t.error;
let p, d, C;
return a ? (p = (A) => this._outputConfiguration.writeErr(A), d = this._outputConfiguration.getErrHasColors(), C = this._outputConfiguration.getErrHelpWidth()) : (p = (A) => this._outputConfiguration.writeOut(A), d = this._outputConfiguration.getOutHasColors(), C = this._outputConfiguration.getOutHelpWidth()), {
error: a,
write: (A) => (d || (A = this._outputConfiguration.stripColor(A)), p(A)),
hasColors: d,
helpWidth: C
};
}
outputHelp(t) {
let a;
typeof t == "function" && (a = t, t = void 0);
const p = this._getOutputContext(t), d = {
error: p.error,
write: p.write,
command: this
};
this._getCommandAndAncestors().reverse().forEach((_) => _.emit(