Skip to content

Commit d0b84d1

Browse files
committed
Runtime: fix rename of directories on windows
1 parent 10f57fe commit d0b84d1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

runtime/js/fs_node.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ class MlNodeDevice {
205205
}
206206
}
207207

208+
slash(name) {
209+
return /\/$/.test(name) ? name : name + "/";
210+
}
211+
208212
rename(o, n, raise_unix) {
209213
if (globalThis.process?.platform === "win32") {
210214
try {
@@ -221,7 +225,7 @@ class MlNodeDevice {
221225
source_stats.isDirectory()
222226
) {
223227
if (target_stats.isDirectory()) {
224-
if (!target.startsWith(source))
228+
if (!this.slash(target).startsWith(this.slash(source)))
225229
try {
226230
this.fs.rmdirSync(target);
227231
} catch {}

0 commit comments

Comments
 (0)