mirror of
https://github.com/better-auth/better-auth.git
synced 2026-07-17 08:20:03 -05:00
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:
5
.changeset/free-impalas-behave.md
Normal file
5
.changeset/free-impalas-behave.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"auth": patch
|
||||
---
|
||||
|
||||
fix(cli): handle directory path passed to --output in generate command
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user