You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you run mock({'/': {}}) on linux '/undefined' will be created in the mocked filesystem.
I think the problem is here, it returns [] if you input '/':
filesystem.js
function getPathParts(filepath) {
var parts = path._makeLong(path.resolve(filepath)).split(path.sep);
parts.shift();
if (isWindows) {
// parts currently looks like ['', '?', 'c:', ...]
parts.shift();
var q = parts.shift(); // should be '?'
var base = '\\\\' + q + '\\' + parts.shift().toLowerCase();
parts.unshift(base);
}
if (parts[parts.length - 1] === '') {
parts.pop();
}
return parts;
}
When it returns to FileSystem.create :
FileSystem.create = function(paths, options) {
var system = new FileSystem(options);
console.log(paths, Object.keys(paths).length)
for (var filepath in paths) {
var parts = getPathParts(filepath);
var directory = system._root;
var i, ii, name, candidate;
for (i = 0, ii = parts.length - 1; i < ii; ++i) {
name = parts[i];
candidate = directory.getItem(name);
if (!candidate) {
directory = directory.addItem(name, new Directory());
} else if (candidate instanceof Directory) {
directory = candidate;
} else {
throw new Error('Failed to create directory: ' + filepath);
}
}
console.log(parts[i], parts)
populate(directory, parts[i], paths[filepath]);
}
return system;
};
It enters the loop and get undefined in parts[i].
So, this is a bug?
The text was updated successfully, but these errors were encountered:
If you run
mock({'/': {}})
on linux '/undefined' will be created in the mocked filesystem.I think the problem is here, it returns
[]
if you input'/'
:When it returns to
FileSystem.create
:It enters the loop and get undefined in
parts[i]
.So, this is a bug?
The text was updated successfully, but these errors were encountered: