feat(format): add check and fix workflows

This commit is contained in:
2026-05-14 13:18:49 +00:00
parent 6f0928e7c7
commit 278df40ba7
11 changed files with 635 additions and 250 deletions
+36 -1
View File
@@ -88,6 +88,41 @@ const parseRawArgv = (argv: string[]): TArgSource => {
return parsedArgv;
};
export const parseCliArgv = parseRawArgv;
export const getProcessUserArgv = (): string[] => {
const rawArgv = process.argv;
const argv0Base = (rawArgv[0] || "").split(/[\\/]/).pop()?.toLowerCase();
const runtimeNames = new Set([
"node",
"node.exe",
"nodejs",
"nodejs.exe",
"bun",
"bun.exe",
"deno",
"deno.exe",
"tsx",
"tsx.exe",
"ts-node",
"ts-node.exe",
]);
if (!runtimeNames.has(argv0Base || "")) {
return rawArgv.slice();
}
const firstUserArg = rawArgv[1] || "";
const firstUserArgLooksLikeScript =
firstUserArg.includes("/") ||
firstUserArg.endsWith(".js") ||
firstUserArg.endsWith(".ts") ||
firstUserArg.endsWith(".mjs") ||
firstUserArg.endsWith(".cjs");
return rawArgv.slice(firstUserArgLooksLikeScript ? 2 : 1);
};
const normalizeOutputMode = (value: unknown): TCliOutputMode | undefined => {
if (value === "human" || value === "plain" || value === "json") {
return value;
@@ -171,7 +206,7 @@ export const getCliMode = async (
export const getRawCliMode = async (): Promise<ICliMode> => {
const cliConfig = await getCliModeConfig();
const rawArgv = parseRawArgv(process.argv.slice(2));
const rawArgv = parseRawArgv(getProcessUserArgv());
return resolveCliMode(rawArgv, cliConfig);
};