Always pass recursive option to capacitor fs mkdir

This commit is contained in:
Alex Gleason committed 2025-10-03 22:38:45 -05:00
1 parent b0f6d38801
commit f420500db2
2 files changed
+7 -8

No files matched your search

+1 -1
View File
@@ -173,7 +173,7 @@ describe('CapacitorFSAdapter', () => {
expect(Filesystem.Filesystem.mkdir).toHaveBeenCalledWith({
path: 'test',
directory: 'DATA',
recursive: false,
recursive: true,
});
});
+6 -7
View File
@@ -162,21 +162,20 @@ export class CapacitorFSAdapter implements JSRuntimeFS {
/**
* Create directory
*/
async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {
async mkdir(path: string): Promise<void> {
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;
}
}