test: update tests, add eslint rules
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { IFileSystem } from "@/ports";
|
||||
|
||||
export class InMemoryFileSystem implements IFileSystem {
|
||||
private files = new Map<string, string>();
|
||||
#files = new Map<string, string>();
|
||||
|
||||
reset(): void {
|
||||
this.files.clear();
|
||||
this.#files.clear();
|
||||
}
|
||||
|
||||
async readFile(path: string): Promise<string> {
|
||||
const content = this.files.get(path);
|
||||
const content = this.#files.get(path);
|
||||
if (content === undefined) {
|
||||
throw new Error(`ENOENT: no such file: ${path}`);
|
||||
}
|
||||
@@ -16,17 +16,17 @@ export class InMemoryFileSystem implements IFileSystem {
|
||||
}
|
||||
|
||||
async writeFile(path: string, content: string): Promise<void> {
|
||||
this.files.set(path, content);
|
||||
this.#files.set(path, content);
|
||||
}
|
||||
|
||||
async deleteFile(path: string): Promise<void> {
|
||||
this.files.delete(path);
|
||||
this.#files.delete(path);
|
||||
}
|
||||
|
||||
async readdir(path: string): Promise<string[]> {
|
||||
const prefix = path.endsWith("/") || path.endsWith("\\") ? path : path + "/";
|
||||
const seen = new Set<string>();
|
||||
for (const key of this.files.keys()) {
|
||||
for (const key of this.#files.keys()) {
|
||||
if (key.startsWith(prefix)) {
|
||||
const relative = key.slice(prefix.length);
|
||||
const top = relative.split(/[/\\]/)[0];
|
||||
|
||||
Reference in New Issue
Block a user