From cfbb9a05243da942d4c5f9fae80077bbccd17f5c Mon Sep 17 00:00:00 2001 From: brone1323 <59184559+brone1323@users.noreply.github.com> Date: Sat, 13 Jun 2026 05:47:44 -0600 Subject: [PATCH] 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 --- .changeset/free-impalas-behave.md | 5 +++++ packages/cli/src/commands/generate.ts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 .changeset/free-impalas-behave.md diff --git a/.changeset/free-impalas-behave.md b/.changeset/free-impalas-behave.md new file mode 100644 index 0000000000..8949cbda54 --- /dev/null +++ b/.changeset/free-impalas-behave.md @@ -0,0 +1,5 @@ +--- +"auth": patch +--- + +fix(cli): handle directory path passed to --output in generate command diff --git a/packages/cli/src/commands/generate.ts b/packages/cli/src/commands/generate.ts index 6411299814..0f212fcc0f 100644 --- a/packages/cli/src/commands/generate.ts +++ b/packages/cli/src/commands/generate.ts @@ -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,