@shetty4l/core 0.1.15 → 0.1.16
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/package.json +1 -1
- package/src/cli.ts +10 -3
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -62,7 +62,8 @@ export interface RunCliOpts {
|
|
|
62
62
|
* Run the CLI: parse process.argv, dispatch to the matching command handler.
|
|
63
63
|
*
|
|
64
64
|
* Handles --help/-h, --version/-v, and unknown commands automatically.
|
|
65
|
-
*
|
|
65
|
+
* If the handler returns a number, exits with that code.
|
|
66
|
+
* If the handler returns void, the process stays alive (for long-running servers).
|
|
66
67
|
*/
|
|
67
68
|
export async function runCli(opts: RunCliOpts): Promise<void> {
|
|
68
69
|
const rawArgs = process.argv.slice(2);
|
|
@@ -104,6 +105,12 @@ export async function runCli(opts: RunCliOpts): Promise<void> {
|
|
|
104
105
|
process.exit(1);
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
const
|
|
108
|
-
|
|
108
|
+
const result = await handler(args, json);
|
|
109
|
+
|
|
110
|
+
// If the handler returned a number, exit with that code.
|
|
111
|
+
// If it returned void/undefined, the command is long-running (e.g. serve)
|
|
112
|
+
// and the process should stay alive.
|
|
113
|
+
if (typeof result === "number") {
|
|
114
|
+
process.exit(result);
|
|
115
|
+
}
|
|
109
116
|
}
|