@reliverse/rempts 1.7.25 → 1.7.26
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.
|
@@ -307,8 +307,15 @@ export async function showUsage(command, parserOptions = {}) {
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
export async function runMain(command, parserOptions = {}) {
|
|
310
|
-
if (typeof command.onLauncherInit === "function")
|
|
311
|
-
|
|
310
|
+
if (typeof command.onLauncherInit === "function") {
|
|
311
|
+
try {
|
|
312
|
+
await command.onLauncherInit();
|
|
313
|
+
} catch (err) {
|
|
314
|
+
relinka("error", "Error in onLauncherInit:", err);
|
|
315
|
+
if (parserOptions.autoExit !== false) process.exit(1);
|
|
316
|
+
throw err;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
312
319
|
try {
|
|
313
320
|
if (!parserOptions.fileBasedCmds && !command.commands) {
|
|
314
321
|
let callerDir = process.cwd();
|
|
@@ -327,26 +334,17 @@ export async function runMain(command, parserOptions = {}) {
|
|
|
327
334
|
}
|
|
328
335
|
if (callerFile) {
|
|
329
336
|
callerDir = path.dirname(callerFile);
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
337
|
+
if (parserOptions.fileBasedCmds?.enable) {
|
|
338
|
+
const rel = path.relative(process.cwd(), callerFile);
|
|
339
|
+
if (/app[/][^/]+[/]cmd\.(ts|js)$/.test(rel)) {
|
|
340
|
+
relinka(
|
|
341
|
+
"error",
|
|
342
|
+
`runMain() should not be called from a file-based subcommand: ${rel}
|
|
335
343
|
This can cause recursion or unexpected behavior.
|
|
336
344
|
Move your runMain() call to your main CLI entry file.`
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const mainEntry = process.argv[1] ? path.resolve(process.argv[1]) : void 0;
|
|
341
|
-
if (mainEntry && path.resolve(callerFile) !== mainEntry) {
|
|
342
|
-
relinka(
|
|
343
|
-
"error",
|
|
344
|
-
`runMain() should only be called from your main CLI entry file.
|
|
345
|
-
Detected: ${callerFile}
|
|
346
|
-
Main entry: ${mainEntry}
|
|
347
|
-
This can cause recursion or unexpected behavior.`
|
|
348
|
-
);
|
|
349
|
-
process.exit(1);
|
|
345
|
+
);
|
|
346
|
+
process.exit(1);
|
|
347
|
+
}
|
|
350
348
|
}
|
|
351
349
|
}
|
|
352
350
|
} catch (_e) {
|