fix(cli): handle directory path passed to --output in generate command (#9564)

Co-authored-by: Maxwell <145994855+ping-maxwell@users.noreply.github.com>
Co-authored-by: ping-maxwell <maxwell.multinite@gmail.com>
This commit is contained in:
brone1323
2026-06-13 05:47:44 -06:00
committed by GitHub
parent b4b02660c7
commit cfbb9a0524
2 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"auth": patch
---
fix(cli): handle directory path passed to --output in generate command

View File

@@ -97,6 +97,22 @@ async function generateAction(opts: any) {
console.error(`The directory "${cwd}" does not exist.`);
process.exit(1);
}
// If --output points to an existing directory, treat it as the output
// directory and append the default filename instead of writing to the
// directory path itself (which causes EISDIR).
if (options.output) {
const resolvedOutput = path.resolve(cwd, options.output);
try {
const stat = await fs.stat(resolvedOutput);
if (stat.isDirectory()) {
options.output = path.join(options.output, "auth-schema.ts");
}
} catch {
// path doesn't exist yet — treat as a file path, which is fine
}
}
const config = await getConfig({
cwd,
configPath: options.config,