hacksh 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -16
- package/dist/{command-D12G9f2b.d.ts → command-BIeWBYyQ.d.ts} +9 -6
- package/dist/index.d.ts +5 -9
- package/dist/index.js +13 -61
- package/dist/index.js.map +1 -1
- package/dist/{pretty-BykhfUqM.js → pretty-MURri0un.js} +111 -2
- package/dist/pretty-MURri0un.js.map +1 -0
- package/dist/printer-api.d.ts +2 -2
- package/dist/printer-api.js +2 -2
- package/package.json +1 -1
- package/dist/pretty-BykhfUqM.js.map +0 -1
package/README.md
CHANGED
|
@@ -128,9 +128,9 @@ const copy = defineCommand({
|
|
|
128
128
|
z.string().meta({ title: "FILES", description: "Input files" }),
|
|
129
129
|
),
|
|
130
130
|
}),
|
|
131
|
-
run({ args }) {
|
|
131
|
+
run({ args, output }) {
|
|
132
132
|
const [destination, ...files] = args.positionals; // [string, ...string[]]
|
|
133
|
-
|
|
133
|
+
output.json({ destination, files });
|
|
134
134
|
},
|
|
135
135
|
});
|
|
136
136
|
```
|
|
@@ -486,8 +486,9 @@ holding the exact text, including the newline `println` adds, or
|
|
|
486
486
|
pretty stdout, except that terminal control sequences are removed as in every JSON string. `json`
|
|
487
487
|
values are normalized like log properties.
|
|
488
488
|
|
|
489
|
-
|
|
490
|
-
`runMain` reports thrown `HackshError` instances on
|
|
489
|
+
`run` return values are exit codes, never command output. Use `output` for data, or keep reusable
|
|
490
|
+
domain functions separate from the handler. `runMain` reports thrown `HackshError` instances on
|
|
491
|
+
stderr and rethrows other exceptions.
|
|
491
492
|
Output that was written before a failure stays written. Like logger calls,
|
|
492
493
|
`output` calls do not need to be awaited and are drained before execution finishes. Writing to
|
|
493
494
|
`process.stdout` or `console.log` directly bypasses the printer, the output mode, and any `stdout`
|
|
@@ -498,8 +499,10 @@ writer given to `runMain` or `runCommand`.
|
|
|
498
499
|
Every `run` context has a `logger`. Its `trace`, `debug`, `info`, `warn`, `error`, and `fatal`
|
|
499
500
|
methods emit structured records through the invocation's printer. `step` and `success` are
|
|
500
501
|
info-level records with a distinct semantic kind for presentation. Placeholders in braces use the
|
|
501
|
-
record's properties.
|
|
502
|
-
|
|
502
|
+
record's properties. By default every level is emitted (`"trace"`); pass `logLevel` on `runMain`
|
|
503
|
+
or `runCommand`, or set `HACKSH_LOG_LEVEL` (which takes precedence), to filter the primary output's
|
|
504
|
+
minimum log level. Thrown command errors are not log records and are always reported regardless of
|
|
505
|
+
`logLevel`.
|
|
503
506
|
|
|
504
507
|
```ts
|
|
505
508
|
const deploy = defineCommand({
|
|
@@ -659,6 +662,30 @@ waits.
|
|
|
659
662
|
|
|
660
663
|
### Cancellation and exit status
|
|
661
664
|
|
|
665
|
+
Handlers return `number | void | Promise<number | void>`. A returned integer from 0 through 255
|
|
666
|
+
is the exit code; `undefined` (including a handler with no return) means 0. Other values, including
|
|
667
|
+
fractions, `NaN`, infinities, out-of-range numbers, and non-numbers, cause a `TypeError`.
|
|
668
|
+
`runCommand` always returns `Promise<number>`: it resolves to the selected handler's exit code,
|
|
669
|
+
or 0 for help, version, or execution without a handler, and propagates thrown errors unchanged.
|
|
670
|
+
It does not print return values or exit the process.
|
|
671
|
+
|
|
672
|
+
```ts
|
|
673
|
+
const health = defineCommand({
|
|
674
|
+
name: "health",
|
|
675
|
+
async run({ signal }) {
|
|
676
|
+
const response = await fetch("https://example.com/health", { signal });
|
|
677
|
+
return response.ok ? 0 : 2;
|
|
678
|
+
},
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
const exitCode = await runCommand(health, []); // number
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
`runMain` drains output before applying the returned exit code. For 0 it sets
|
|
685
|
+
`process.exitCode = 0` and lets the process finish naturally; for a nonzero code it calls
|
|
686
|
+
`process.exit(code)`. Returning a nonzero code does not report an error or call `onError`.
|
|
687
|
+
Invalid returns reject with `TypeError`, without CLI error reporting or a forced exit.
|
|
688
|
+
|
|
662
689
|
Every `run` context has a `signal`, an `AbortSignal` for that invocation. `exec` calls and prompts
|
|
663
690
|
already follow it; pass it to `fetch` and other APIs that accept one. Cancellation is cooperative:
|
|
664
691
|
hacksh does not stop code that ignores the signal.
|
|
@@ -689,9 +716,10 @@ output is drained and the process exits with 130 for `SIGINT` or 143 for `SIGTER
|
|
|
689
716
|
exceptions and output failures still reject instead of being converted to a signal exit.
|
|
690
717
|
A second signal while the invocation is pending exits immediately with that signal's status.
|
|
691
718
|
|
|
692
|
-
|
|
719
|
+
Alternatively, throw `HackshExitError(exitCode, message?)` to choose an exit status from 0 to 255.
|
|
693
720
|
`runMain` prints a non-empty message as an ordinary CLI error and prints nothing when the message
|
|
694
|
-
is omitted; `onError` still receives the error. `
|
|
721
|
+
is omitted; `onError` still receives the error. This error path calls `process.exit` even for 0.
|
|
722
|
+
`runCommand` rejects with the error unchanged.
|
|
695
723
|
Other `HackshError` instances exit with 1, or 130 for a cancelled prompt.
|
|
696
724
|
|
|
697
725
|
## Output formats
|
|
@@ -765,14 +793,15 @@ the semantic events that the command emits.
|
|
|
765
793
|
|
|
766
794
|
### Entry points
|
|
767
795
|
|
|
768
|
-
`defineCommand`
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
796
|
+
`defineCommand` accepts handlers returning `number | void | Promise<number | void>`; it does not
|
|
797
|
+
infer arbitrary result types. `CommandDef<S, Children>` describes the argument schema and child
|
|
798
|
+
commands, without a result type parameter. `runCommand(command, argv, options)` returns
|
|
799
|
+
`Promise<number>`: an integer exit code from 0 through 255, with `undefined`, help, version, and
|
|
800
|
+
execution without a handler normalized to 0. Invalid return values reject with `TypeError`.
|
|
772
801
|
Thrown exceptions, argument errors, and output failures reject the promise. `runCommand` never
|
|
773
802
|
exits or automatically prints a return value or error.
|
|
774
803
|
|
|
775
|
-
`runMain(command)` reads `process.argv`,
|
|
804
|
+
`runMain(command)` reads `process.argv`, applies the returned exit code, and only handles thrown
|
|
776
805
|
`HackshError` instances as normal CLI failures. Other exceptions reject without automatic error
|
|
777
806
|
display, `onError`, or process exit. Pending output is drained and signal listeners are removed
|
|
778
807
|
on both success and rejection. Output failures also reject, including while reporting a CLI
|
|
@@ -836,12 +865,13 @@ function loadUser(id: string) {
|
|
|
836
865
|
|
|
837
866
|
const schema = z.object({ id: z.string() });
|
|
838
867
|
|
|
839
|
-
function run({ args }: CommandContext<typeof schema>) {
|
|
868
|
+
function run({ args, output }: CommandContext<typeof schema>) {
|
|
840
869
|
try {
|
|
841
|
-
|
|
870
|
+
output.json(loadUser(args.id));
|
|
842
871
|
} catch (error) {
|
|
843
872
|
if (error instanceof NotFoundError) {
|
|
844
|
-
|
|
873
|
+
output.json({ id: error.id, displayName: "Guest" });
|
|
874
|
+
return;
|
|
845
875
|
}
|
|
846
876
|
throw error;
|
|
847
877
|
}
|
|
@@ -135,7 +135,10 @@ interface HackshErrorSummary {
|
|
|
135
135
|
}
|
|
136
136
|
//#endregion
|
|
137
137
|
//#region src/logger.d.ts
|
|
138
|
-
|
|
138
|
+
declare const LOG_LEVELS: readonly ["trace", "debug", "info", "warning", "error", "fatal"];
|
|
139
|
+
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
140
|
+
/** Wrap a printer so only log events at or above `minLevel` are forwarded; non-log events always pass through. */
|
|
141
|
+
declare function filterLogPrinter(printer: Printer, minLevel: LogLevel): Printer;
|
|
139
142
|
type LogKind = "message" | "step" | "success";
|
|
140
143
|
type LogProperties = Record<string, unknown>;
|
|
141
144
|
/** A structured message emitted by a command's logger. */
|
|
@@ -426,7 +429,7 @@ interface CommandContext<S extends ArgsSchema> {
|
|
|
426
429
|
exec: Exec;
|
|
427
430
|
signal: AbortSignal;
|
|
428
431
|
}
|
|
429
|
-
interface CommandDef<S extends ArgsSchema = EmptyArgs,
|
|
432
|
+
interface CommandDef<S extends ArgsSchema = EmptyArgs, Children extends Record<string, AnyCommandDef> = Record<string, AnyCommandDef>> {
|
|
430
433
|
name?: string;
|
|
431
434
|
version?: string;
|
|
432
435
|
description?: string;
|
|
@@ -435,10 +438,10 @@ interface CommandDef<S extends ArgsSchema = EmptyArgs, R = unknown, Children ext
|
|
|
435
438
|
allowUnknownArgs?: boolean;
|
|
436
439
|
args?: S;
|
|
437
440
|
subCommands?: Children;
|
|
438
|
-
run?(context: CommandContext<S>):
|
|
441
|
+
run?(context: CommandContext<S>): number | void | Promise<number | void>;
|
|
439
442
|
}
|
|
440
443
|
type AnyCommandDef = CommandDef<ArgsSchema>;
|
|
441
|
-
declare function defineCommand<S extends ArgsSchema = EmptyArgs,
|
|
444
|
+
declare function defineCommand<S extends ArgsSchema = EmptyArgs, Children extends Record<string, AnyCommandDef> = {}>(def: CommandDef<S, Children>): NoInfer<CommandDef<S, Children>>;
|
|
442
445
|
//#endregion
|
|
443
|
-
export { LogProperties as $, PromptState as A, WaitPromptState as B, OutputPrintEvent as C,
|
|
444
|
-
//# sourceMappingURL=command-
|
|
446
|
+
export { LogProperties as $, PromptState as A, WaitPromptState as B, OutputPrintEvent as C, ExecSkipped as Ct, Printer as D, PrintStream as E, TerminalInput as F, UsageCommandSummary as G, resolveOutputMode as H, TerminalOutput as I, renderUsage as J, UsageOptionSummary as K, TextPromptState as L, ResolveOutputModeOptions as M, SelectPromptState as N, PromptChoiceState as O, StreamColors as P, LogLevel as Q, UsagePrintEvent as R, OutputPreference as S, ExecReturn as St, PrintEvent as T, ShowUsageOptions as U, createJsonPrinter as V, UsageArgumentSummary as W, summarizeUsage as X, showUsage as Y, LogKind as Z, ExecPrintEvent as _, ExecCommand as _t, ArgsSchema as a, HackshErrorSummary as at, OutputFormat as b, ExecOptions as bt, Prompter as c, HackshIssue as ct, TextOptions as d, HackshUsageError as dt, LogRecord as et, WaitOptions as f, HackshValidationError as ft, ErrorPrintEvent as g, Exec as gt, ConfirmPromptState as h, ValidationIssueSummary as ht, defineCommand as i, HackshErrorKind as it, PromptStatus as j, PromptPrintEvent as k, SelectOption as l, HackshPromptError as lt, AutocompletePromptState as m, PromptKind as mt, CommandContext as n, filterLogPrinter as nt, AutocompleteOptions as o, HackshExecError as ot, Output as p, PromptErrorDetails as pt, UsageSummary as q, CommandDef as r, HackshError as rt, ConfirmOptions as s, HackshExitError as st, AnyCommandDef as t, Logger as tt, SelectOptions as u, HackshPromptErrorReason as ut, JsonPrinterOptions as v, ExecFailure as vt, OutputWriter as w, ExecSuccess as wt, OutputMode as x, ExecResult as xt, LogPrintEvent as y, ExecFailureReason as yt, VersionPrintEvent as z };
|
|
447
|
+
//# sourceMappingURL=command-BIeWBYyQ.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ct as
|
|
1
|
+
import { Ct as ExecSkipped, D as Printer, F as TerminalInput, I as TerminalOutput, J as renderUsage, Q as LogLevel, S as OutputPreference, St as ExecReturn, U as ShowUsageOptions, X as summarizeUsage, Y as showUsage, _t as ExecCommand, a as ArgsSchema, bt as ExecOptions, c as Prompter, ct as HackshIssue, d as TextOptions, dt as HackshUsageError, f as WaitOptions, ft as HackshValidationError, gt as Exec, i as defineCommand, l as SelectOption, lt as HackshPromptError, mt as PromptKind, n as CommandContext, o as AutocompleteOptions, ot as HackshExecError, p as Output, pt as PromptErrorDetails, r as CommandDef, rt as HackshError, s as ConfirmOptions, st as HackshExitError, t as AnyCommandDef, tt as Logger, u as SelectOptions, ut as HackshPromptErrorReason, vt as ExecFailure, wt as ExecSuccess, xt as ExecResult, yt as ExecFailureReason } from "./command-BIeWBYyQ.js";
|
|
2
2
|
import { output } from "zod/v4/core";
|
|
3
3
|
//#region src/parser.d.ts
|
|
4
4
|
/**
|
|
@@ -14,6 +14,8 @@ interface OutputOptions {
|
|
|
14
14
|
output?: OutputPreference;
|
|
15
15
|
/** Use Unicode presentation symbols in pretty output. Defaults to true. */
|
|
16
16
|
unicode?: boolean;
|
|
17
|
+
/** Minimum log level emitted to the primary output printer. Defaults to "trace". */
|
|
18
|
+
logLevel?: LogLevel;
|
|
17
19
|
env?: Readonly<Record<string, string | undefined>>;
|
|
18
20
|
stdin?: TerminalInput;
|
|
19
21
|
stdout?: TerminalOutput;
|
|
@@ -25,13 +27,7 @@ interface RunCommandOptions extends OutputOptions {
|
|
|
25
27
|
printer?: Printer;
|
|
26
28
|
signal?: AbortSignal;
|
|
27
29
|
}
|
|
28
|
-
|
|
29
|
-
run?: infer Handler;
|
|
30
|
-
} ? Handler extends ((...args: never[]) => infer R) ? Awaited<R> : never : never;
|
|
31
|
-
type CommandResult<C> = HandlerResult<C> | (C extends {
|
|
32
|
-
subCommands?: infer Children;
|
|
33
|
-
} ? Children extends Record<string, AnyCommandDef> ? string extends keyof Children ? unknown : CommandResult<Children[keyof Children]> : never : never);
|
|
34
|
-
declare function runCommand<C extends AnyCommandDef>(root: C, argv: string[], options?: RunCommandOptions): Promise<CommandResult<C> | undefined>;
|
|
30
|
+
declare function runCommand(root: AnyCommandDef, argv: string[], options?: RunCommandOptions): Promise<number>;
|
|
35
31
|
interface RunMainOptions extends OutputOptions {
|
|
36
32
|
onError?: (error: HackshError) => void | Promise<void>;
|
|
37
33
|
argv?: string[];
|
|
@@ -39,5 +35,5 @@ interface RunMainOptions extends OutputOptions {
|
|
|
39
35
|
}
|
|
40
36
|
declare function runMain<S extends ArgsSchema>(command: CommandDef<S>, options?: RunMainOptions): Promise<void>;
|
|
41
37
|
//#endregion
|
|
42
|
-
export { type AutocompleteOptions, type CommandContext, type CommandDef, type ConfirmOptions, type Exec, type ExecCommand, type ExecFailure, type ExecFailureReason, type ExecOptions, type ExecResult, type ExecReturn, type ExecSkipped, type ExecSuccess, HackshError, HackshExecError, HackshExitError, type HackshIssue, HackshPromptError, type HackshPromptErrorReason, HackshUsageError, HackshValidationError, type Logger, type Output, type OutputOptions, type PromptErrorDetails, type PromptKind, type Prompter, type RunCommandOptions, type RunMainOptions, type SelectOption, type SelectOptions, type ShowUsageOptions, type TextOptions, type WaitOptions, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage, summarizeUsage };
|
|
38
|
+
export { type AutocompleteOptions, type CommandContext, type CommandDef, type ConfirmOptions, type Exec, type ExecCommand, type ExecFailure, type ExecFailureReason, type ExecOptions, type ExecResult, type ExecReturn, type ExecSkipped, type ExecSuccess, HackshError, HackshExecError, HackshExitError, type HackshIssue, HackshPromptError, type HackshPromptErrorReason, HackshUsageError, HackshValidationError, type LogLevel, type Logger, type Output, type OutputOptions, type PromptErrorDetails, type PromptKind, type Prompter, type RunCommandOptions, type RunMainOptions, type SelectOption, type SelectOptions, type ShowUsageOptions, type TextOptions, type WaitOptions, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage, summarizeUsage };
|
|
43
39
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as createLogger, c as createExec, d as HackshExitError, f as HackshPromptError, g as summarizeErrors, h as summarizeError, i as resolveOutputMode, l as HackshError, m as HackshValidationError, n as createJsonPrinter, o as filterLogPrinter, p as HackshUsageError, r as createPrintQueue, s as resolveLogLevel, t as createPrettyPrinter, u as HackshExecError } from "./pretty-MURri0un.js";
|
|
2
2
|
import { globalRegistry, safeParseAsync } from "zod/v4/core";
|
|
3
3
|
import { parseArgs as parseArgs$1 } from "node:util";
|
|
4
4
|
import { readFile, realpath } from "node:fs/promises";
|
|
@@ -512,61 +512,6 @@ var TerminalLock = class {
|
|
|
512
512
|
}
|
|
513
513
|
};
|
|
514
514
|
//#endregion
|
|
515
|
-
//#region src/logger.ts
|
|
516
|
-
function interpolate(message, properties) {
|
|
517
|
-
return message.replace(/\{([^{}]+)\}/g, (placeholder, key) => {
|
|
518
|
-
if (!Object.hasOwn(properties, key)) return placeholder;
|
|
519
|
-
try {
|
|
520
|
-
return String(properties[key]);
|
|
521
|
-
} catch {
|
|
522
|
-
return placeholder;
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
function createBoundLogger(printer, category, boundProperties) {
|
|
527
|
-
function emit(level, kind, input, properties = {}) {
|
|
528
|
-
const rawMessage = input instanceof Error ? input.message : input;
|
|
529
|
-
const mergedProperties = {
|
|
530
|
-
...boundProperties,
|
|
531
|
-
...properties
|
|
532
|
-
};
|
|
533
|
-
if (input instanceof Error) mergedProperties.error = input;
|
|
534
|
-
const summarizedProperties = summarizeErrors(mergedProperties);
|
|
535
|
-
printer.print({
|
|
536
|
-
type: "log",
|
|
537
|
-
record: {
|
|
538
|
-
level,
|
|
539
|
-
kind,
|
|
540
|
-
category,
|
|
541
|
-
message: interpolate(rawMessage, mergedProperties),
|
|
542
|
-
rawMessage,
|
|
543
|
-
properties: summarizedProperties,
|
|
544
|
-
timestamp: Date.now()
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
return {
|
|
549
|
-
category,
|
|
550
|
-
trace: (message, properties) => emit("trace", "message", message, properties),
|
|
551
|
-
debug: (message, properties) => emit("debug", "message", message, properties),
|
|
552
|
-
info: (message, properties) => emit("info", "message", message, properties),
|
|
553
|
-
warn: (message, properties) => emit("warning", "message", message, properties),
|
|
554
|
-
error: (message, properties) => emit("error", "message", message, properties),
|
|
555
|
-
fatal: (message, properties) => emit("fatal", "message", message, properties),
|
|
556
|
-
step: (message, properties) => emit("info", "step", message, properties),
|
|
557
|
-
success: (message, properties) => emit("info", "success", message, properties),
|
|
558
|
-
with: (properties) => createBoundLogger(printer, category, {
|
|
559
|
-
...boundProperties,
|
|
560
|
-
...properties
|
|
561
|
-
}),
|
|
562
|
-
getChild: (child) => createBoundLogger(printer, [...category, child], boundProperties)
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
/** Create the logger for one command invocation. */
|
|
566
|
-
function createLogger(printer, category) {
|
|
567
|
-
return createBoundLogger(printer, [...category], {});
|
|
568
|
-
}
|
|
569
|
-
//#endregion
|
|
570
515
|
//#region src/package-version.ts
|
|
571
516
|
async function findPackageVersion(entry) {
|
|
572
517
|
if (!entry) return void 0;
|
|
@@ -1257,18 +1202,18 @@ async function executeCommand(root, argv, output, env, signal, fallbackVersion =
|
|
|
1257
1202
|
type: "version",
|
|
1258
1203
|
version
|
|
1259
1204
|
});
|
|
1260
|
-
return;
|
|
1205
|
+
return 0;
|
|
1261
1206
|
}
|
|
1262
1207
|
if (resolved.segments.some(({ tokenized }) => tokenized.help)) {
|
|
1263
1208
|
await showUsage(resolved.command, { printer });
|
|
1264
|
-
return;
|
|
1209
|
+
return 0;
|
|
1265
1210
|
}
|
|
1266
1211
|
for (const parent of resolved.parents) await parseCommandArgs(parent.command, parent.rawArgs, parent.tokenized, argEnv, commandEnvPath(parent.command));
|
|
1267
1212
|
const parsed = await parseCommandArgs(resolved.command, resolved.rawArgs, resolved.tokenized, argEnv, commandEnvPath(resolved.command));
|
|
1268
1213
|
if (!resolved.command.run) throw new HackshUsageError("No command specified", resolved.command);
|
|
1269
1214
|
signal.throwIfAborted();
|
|
1270
1215
|
const category = resolved.segments.flatMap(({ command }) => command.name === void 0 ? [] : [command.name]);
|
|
1271
|
-
|
|
1216
|
+
const result = await resolved.command.run({
|
|
1272
1217
|
command: resolved.command,
|
|
1273
1218
|
args: parsed.args,
|
|
1274
1219
|
input: {
|
|
@@ -1297,6 +1242,9 @@ async function executeCommand(root, argv, output, env, signal, fallbackVersion =
|
|
|
1297
1242
|
}),
|
|
1298
1243
|
signal
|
|
1299
1244
|
});
|
|
1245
|
+
if (result === void 0) return 0;
|
|
1246
|
+
if (typeof result !== "number" || !Number.isInteger(result) || result < 0 || result > 255) throw new TypeError("Exit code must be an integer from 0 to 255");
|
|
1247
|
+
return result;
|
|
1300
1248
|
}
|
|
1301
1249
|
function prepareOutput(options, env) {
|
|
1302
1250
|
const input = options.stdin ?? process.stdin;
|
|
@@ -1307,8 +1255,10 @@ function prepareOutput(options, env) {
|
|
|
1307
1255
|
outputIsTTY: (options.stdout ?? process.stdout).isTTY,
|
|
1308
1256
|
errorOutputIsTTY: (options.stderr ?? process.stderr).isTTY
|
|
1309
1257
|
});
|
|
1258
|
+
const logLevel = resolveLogLevel(options.logLevel, env);
|
|
1259
|
+
const printer = filterLogPrinter(selectOutputPrinter(options, options.printer, mode), logLevel);
|
|
1310
1260
|
return {
|
|
1311
|
-
...createPrintQueue(
|
|
1261
|
+
...createPrintQueue(printer),
|
|
1312
1262
|
format: mode.format,
|
|
1313
1263
|
interactive: mode.interactive,
|
|
1314
1264
|
input,
|
|
@@ -1368,7 +1318,8 @@ async function runMain(command, options = {}) {
|
|
|
1368
1318
|
let exitCode;
|
|
1369
1319
|
try {
|
|
1370
1320
|
try {
|
|
1371
|
-
await executeCommand(command, options.argv ?? process.argv.slice(2), output, options.env, signals.signal, () => findPackageVersion(process.argv[1]));
|
|
1321
|
+
const result = await executeCommand(command, options.argv ?? process.argv.slice(2), output, options.env, signals.signal, () => findPackageVersion(process.argv[1]));
|
|
1322
|
+
if (result !== 0) exitCode = result;
|
|
1372
1323
|
} catch (error) {
|
|
1373
1324
|
const signalExitCode = signals.exitCode();
|
|
1374
1325
|
if (signalExitCode !== void 0 && error === signals.signal.reason) exitCode = signalExitCode;
|
|
@@ -1388,6 +1339,7 @@ async function runMain(command, options = {}) {
|
|
|
1388
1339
|
}
|
|
1389
1340
|
const code = signals.exitCode() ?? exitCode;
|
|
1390
1341
|
if (code !== void 0) process.exit(code);
|
|
1342
|
+
else process.exitCode = 0;
|
|
1391
1343
|
}
|
|
1392
1344
|
//#endregion
|
|
1393
1345
|
export { HackshError, HackshExecError, HackshExitError, HackshPromptError, HackshUsageError, HackshValidationError, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage, summarizeUsage };
|