mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix typecheck issues
This commit is contained in:
1 file changed
+31
-2
+31
-2
@@ -40,7 +40,10 @@ class MockFS implements JSRuntimeFS {
|
||||
}
|
||||
}
|
||||
|
||||
async readdir(path: string): Promise<string[]> {
|
||||
async readdir(path: string): Promise<string[]>;
|
||||
async readdir(path: string, options: { withFileTypes: true }): Promise<import('./JSRuntime').DirectoryEntry[]>;
|
||||
async readdir(path: string, options?: { withFileTypes?: boolean }): Promise<string[] | import('./JSRuntime').DirectoryEntry[]>;
|
||||
async readdir(path: string, options?: { withFileTypes?: boolean }): Promise<string[] | import('./JSRuntime').DirectoryEntry[]> {
|
||||
if (!this.dirs.has(path)) throw new Error(`ENOENT: ${path}`);
|
||||
|
||||
const entries = new Set<string>();
|
||||
@@ -64,7 +67,21 @@ class MockFS implements JSRuntimeFS {
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(entries);
|
||||
const names = Array.from(entries);
|
||||
|
||||
if (options?.withFileTypes) {
|
||||
return names.map(name => {
|
||||
const fullPath = path === '/' ? `/${name}` : `${path}/${name}`;
|
||||
const isDir = this.dirs.has(fullPath);
|
||||
return {
|
||||
name,
|
||||
isDirectory: () => isDir,
|
||||
isFile: () => !isDir,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {
|
||||
@@ -125,6 +142,18 @@ class MockFS implements JSRuntimeFS {
|
||||
this.files.delete(oldPath);
|
||||
}
|
||||
}
|
||||
|
||||
async lstat(path: string): Promise<{ isDirectory: () => boolean; isFile: () => boolean }> {
|
||||
return this.stat(path);
|
||||
}
|
||||
|
||||
async readlink(_path: string): Promise<string> {
|
||||
throw new Error('Symlinks not supported in MockFS');
|
||||
}
|
||||
|
||||
async symlink(_target: string, _path: string): Promise<void> {
|
||||
throw new Error('Symlinks not supported in MockFS');
|
||||
}
|
||||
}
|
||||
|
||||
describe('plugins', () => {
|
||||
|
||||
Reference in new issue
Block a user