diff --git a/src/lib/CapacitorFSAdapter.test.ts b/src/lib/CapacitorFSAdapter.test.ts index 6b314794..ffdf896f 100644 --- a/src/lib/CapacitorFSAdapter.test.ts +++ b/src/lib/CapacitorFSAdapter.test.ts @@ -173,7 +173,7 @@ describe('CapacitorFSAdapter', () => { expect(Filesystem.Filesystem.mkdir).toHaveBeenCalledWith({ path: 'test', directory: 'DATA', - recursive: false, + recursive: true, }); }); diff --git a/src/lib/CapacitorFSAdapter.ts b/src/lib/CapacitorFSAdapter.ts index 13c9f6b0..1d745e2c 100644 --- a/src/lib/CapacitorFSAdapter.ts +++ b/src/lib/CapacitorFSAdapter.ts @@ -162,21 +162,20 @@ export class CapacitorFSAdapter implements JSRuntimeFS { /** * Create directory */ - async mkdir(path: string, options?: { recursive?: boolean }): Promise { + async mkdir(path: string): Promise { try { await Filesystem.mkdir({ path: this.normalizePath(path), directory: this.baseDirectory, - recursive: options?.recursive ?? false, + recursive: true, }); } catch (error) { // Ignore "directory exists" errors when recursive is true - if (options?.recursive && error instanceof Error) { - if (error.message.includes('exists') || error.message.includes('EEXIST')) { - return; - } + if (error instanceof Error && (error.message.includes('exists') || error.message.includes('EEXIST'))) { + return; + } else { + throw error; } - throw error; } }