From 66b6fe510dd3e9f07064cdb4317c3d96bb3d1b48 Mon Sep 17 00:00:00 2001 From: Sourabh Desai <sourabhdesai@gmail.com> Date: Tue, 27 Jun 2023 06:58:35 +0000 Subject: [PATCH] fix access() implementation for in memory fs --- packages/core/src/storage/FileSystem.ts | 8 +++++--- ...MemoryFileSystem.test.ts => GenericFileSystem.test.ts} | 0 2 files changed, 5 insertions(+), 3 deletions(-) rename packages/core/src/tests/{InMemoryFileSystem.test.ts => GenericFileSystem.test.ts} (100%) diff --git a/packages/core/src/storage/FileSystem.ts b/packages/core/src/storage/FileSystem.ts index 9ac5e15ec..35a95a897 100644 --- a/packages/core/src/storage/FileSystem.ts +++ b/packages/core/src/storage/FileSystem.ts @@ -9,7 +9,7 @@ import _ from "lodash"; export interface GenericFileSystem { writeFile(path: string, content: string, options?: any): Promise<void>; readFile(path: string, options?: any): Promise<string>; - access(path: string): Promise<boolean>; + access(path: string): Promise<void>; mkdir(path: string, options?: any): Promise<void>; } @@ -35,8 +35,10 @@ export class InMemoryFileSystem implements GenericFileSystem { return _.cloneDeep(this.files[path]); } - async access(path: string): Promise<boolean> { - return path in this.files; + async access(path: string): Promise<void> { + if (!(path in this.files)) { + throw new Error(`File ${path} does not exist`); + } } async mkdir(path: string, options?: any): Promise<void> { diff --git a/packages/core/src/tests/InMemoryFileSystem.test.ts b/packages/core/src/tests/GenericFileSystem.test.ts similarity index 100% rename from packages/core/src/tests/InMemoryFileSystem.test.ts rename to packages/core/src/tests/GenericFileSystem.test.ts -- GitLab