Skip to content

creates undefined directoriesΒ #325

@heygrady

Description

@heygrady

Was comparing memfs and memory-fs and was failing a test. Discovered that memfs will create undefined directories when you fs.mkdirSync("/"); and that directory already exists.

// test.js
const {Volume} = require("memfs");

var fs = new Volume();

// snippet from https://github.com/webpack/memory-fs/blob/master/test/MemoryFileSystem.js#L18
fs.mkdirSync("/test");
console.log(fs.readdirSync("/"));
fs.mkdirSync("/test//sub/");
console.log(fs.readdirSync("/"));
fs.mkdirpSync("/test/sub2");
console.log(fs.readdirSync("/"));
fs.mkdirSync("/root\\dir");
console.log(fs.readdirSync("/"));
fs.mkdirpSync("/");
console.log(fs.readdirSync("/"));
fs.mkdirSync("/"); // <-- this should probably throw; creates an "undefined" folder instead
console.log(fs.readdirSync("/")); // --> [ 'root\\dir', 'test', 'undefined' ]
$ node test.js
[ 'test' ]
[ 'test' ]
[ 'test' ]
[ 'root\\dir', 'test' ]
[ 'root\\dir', 'test' ]
[ 'root\\dir', 'test', 'undefined' ]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions