@reliverse/rempts 1.7.26 → 1.7.27
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.
|
@@ -318,41 +318,13 @@ export async function runMain(command, parserOptions = {}) {
|
|
|
318
318
|
}
|
|
319
319
|
try {
|
|
320
320
|
if (!parserOptions.fileBasedCmds && !command.commands) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const stack = err.stack?.split("\n");
|
|
326
|
-
if (stack) {
|
|
327
|
-
for (const line of stack) {
|
|
328
|
-
const match = /\((.*):(\d+):(\d+)\)/.exec(line) || /at (.*):(\d+):(\d+)/.exec(line);
|
|
329
|
-
if (match?.[1] && !match[1].includes("launcher-mod")) {
|
|
330
|
-
callerFile = match[1];
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
if (callerFile) {
|
|
336
|
-
callerDir = path.dirname(callerFile);
|
|
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}
|
|
343
|
-
This can cause recursion or unexpected behavior.
|
|
344
|
-
Move your runMain() call to your main CLI entry file.`
|
|
345
|
-
);
|
|
346
|
-
process.exit(1);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
} catch (_e) {
|
|
351
|
-
}
|
|
352
|
-
const defaultCmdsRoot = path.resolve(callerDir, "app");
|
|
321
|
+
const mainEntry = process.argv[1] ? path.dirname(path.resolve(process.argv[1])) : process.cwd();
|
|
322
|
+
const defaultCmdsRoot = path.join(mainEntry, "src", "app");
|
|
323
|
+
const exists = await fs.pathExists(defaultCmdsRoot);
|
|
324
|
+
const finalCmdsRoot = exists ? defaultCmdsRoot : path.join(mainEntry, "app");
|
|
353
325
|
parserOptions.fileBasedCmds = {
|
|
354
326
|
enable: true,
|
|
355
|
-
cmdsRootPath:
|
|
327
|
+
cmdsRootPath: finalCmdsRoot
|
|
356
328
|
};
|
|
357
329
|
}
|
|
358
330
|
const rawArgv = process.argv.slice(2);
|