fix(cli): gracefulExit not called when failing to parse arg

This commit is contained in:
Tat Dat Duong
2025-02-26 23:46:26 +01:00
parent bfa798a37f
commit a31b32af06
4 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -13,7 +13,7 @@ import * as path from "node:path";
import * as fs from "node:fs/promises";
import { logger } from "../utils/logging.mjs";
import { withAnalytics } from "./utils/analytics.mjs";
import { gracefulExit } from "exit-hook";
const stream = <T extends { spawnargs: string[] }>(proc: T): T => {
logger.info(`Running "${proc.spawnargs.join(" ")}"`);
return proc;
@@ -30,6 +30,7 @@ builder
)
.argument("[args...]")
.passThroughOptions()
.exitOverride((error) => gracefulExit(error.exitCode))
.hook(
"preAction",
withAnalytics((command) => ({
+2
View File
@@ -13,6 +13,7 @@ import { getConfig } from "../utils/config.mjs";
import { builder } from "./utils/builder.mjs";
import { logError, logger } from "../utils/logging.mjs";
import { withAnalytics } from "./utils/analytics.mjs";
import { gracefulExit } from "exit-hook";
builder
.command("dev")
@@ -26,6 +27,7 @@ builder
.option("-c, --config <path>", "path to configuration file", process.cwd())
.allowExcessArguments()
.allowUnknownOption()
.exitOverride((error) => gracefulExit(error.exitCode))
.hook(
"preAction",
withAnalytics((command) => ({
+2
View File
@@ -12,6 +12,7 @@ import * as path from "node:path";
import dedent from "dedent";
import { logger } from "../utils/logging.mjs";
import { withAnalytics } from "./utils/analytics.mjs";
import { gracefulExit } from "exit-hook";
const fileExists = async (path: string) => {
try {
@@ -33,6 +34,7 @@ builder
"Add additional files for running the LangGraph API server with docker-compose. These files include a docker-compose.yml, .env file, and a .dockerignore file.",
)
.option("-c, --config <path>", "Path to configuration file", process.cwd())
.exitOverride((error) => gracefulExit(error.exitCode))
.hook(
"preAction",
withAnalytics((command) => ({
+2
View File
@@ -11,6 +11,7 @@ import { $ } from "execa";
import { createHash } from "node:crypto";
import dedent from "dedent";
import { withAnalytics } from "./utils/analytics.mjs";
import { gracefulExit } from "exit-hook";
const sha256 = (input: string) =>
createHash("sha256").update(input).digest("hex");
@@ -64,6 +65,7 @@ builder
"--postgres-uri <uri>",
"Postgres URI to use for the database. Defaults to launching a local database",
)
.exitOverride((error) => gracefulExit(error.exitCode))
.hook(
"preAction",
withAnalytics((command) => ({