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,