File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " wrangler " : patch
3+ ---
4+
5+ Improve error message when ` d1 export --output ` points to a directory
Original file line number Diff line number Diff line change @@ -24,6 +24,16 @@ describe("export", () => {
2424 ) ;
2525 } ) ;
2626
27+ it ( "should throw if output is a directory" , async ( ) => {
28+ fs . mkdirSync ( "test-dir" ) ;
29+
30+ await expect (
31+ runWrangler ( "d1 export db --output test-dir" )
32+ ) . rejects . toThrowError (
33+ `Please specify a file path for --output, not a directory.`
34+ ) ;
35+ } ) ;
36+
2737 it ( "should throw if local and remote are both set" , async ( ) => {
2838 await expect (
2939 runWrangler ( "d1 export db --local --remote --output test-local.sql" )
Original file line number Diff line number Diff line change 1+ import { statSync } from "node:fs" ;
12import fs from "node:fs/promises" ;
23import path from "node:path" ;
34import { spinner , spinnerWhile } from "@cloudflare/cli/interactive" ;
@@ -82,6 +83,13 @@ export const d1ExportCommand = createCommand({
8283 throw new UserError ( `You cannot specify both --no-schema and --no-data` ) ;
8384 }
8485
86+ const stats = statSync ( output , { throwIfNoEntry : false } ) ;
87+ if ( stats ?. isDirectory ( ) ) {
88+ throw new UserError (
89+ `Please specify a file path for --output, not a directory.`
90+ ) ;
91+ }
92+
8593 // Allow multiple --table x --table y flags or none
8694 const tables : string [ ] = table
8795 ? Array . isArray ( table )
You can’t perform that action at this time.
0 commit comments