Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit 1c36bc6

Browse files
committed
fix operation on _remove
1 parent 501f381 commit 1c36bc6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/MemoryFileSystem.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,19 @@ class MemoryFileSystem {
168168

169169
_remove(_path, name, testFn) {
170170
const path = pathToArray(_path);
171+
const operation = name === "File" ? "unlink" : "rmdir";
171172
if(path.length === 0) {
172-
throw new MemoryFileSystemError(errors.code.EPERM, _path, "remove");
173+
throw new MemoryFileSystemError(errors.code.EPERM, _path, operation);
173174
}
174175
let current = this.data;
175176
let i = 0;
176177
for(; i < path.length - 1; i++) {
177178
if(!isDir(current[path[i]]))
178-
throw new MemoryFileSystemError(errors.code.ENOENT, _path, "remove");
179+
throw new MemoryFileSystemError(errors.code.ENOENT, _path, operation);
179180
current = current[path[i]];
180181
}
181182
if(!testFn(current[path[i]]))
182-
throw new MemoryFileSystemError(errors.code.ENOENT, _path, "remove");
183+
throw new MemoryFileSystemError(errors.code.ENOENT, _path, operation);
183184
delete current[path[i]];
184185
return;
185186
}

0 commit comments

Comments
 (0)