-
-
Notifications
You must be signed in to change notification settings - Fork 143
Closed
Labels
Description
Using memfs:
const { fs } = require('memfs');
fs.writeFileSync('/foo', 'hello');
console.log(fs.readFileSync('/foo/', 'utf8')); // logs 'hello'Using the builtin fs (on Linux):
const fs = require('node:fs');
fs.writeFileSync('/foo', 'hello');
console.log(fs.readFileSync('/foo/', 'utf8')); // throws ENOTDIRUsing the builtin fs (on Windows):
const fs = require('node:fs');
fs.writeFileSync('C:/foo', 'hello');
console.log(fs.readFileSync('C:/foo/', 'utf8')); // logs 'hello'I think a trailing slash means the path is intended to point at a folder, so trying to read from it should throw.
Not sure why Windows is weird, maybe the behavior should differ based on isWin.
Tested with memfs v4.11.1 and Node.js v20.12.2
Reactions are currently unavailable