Skip to content

Commit

Permalink
fix root paths which were not considered as directories [closes #15]
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkudera committed Jun 20, 2015
1 parent 3686861 commit d01f06e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,13 @@
return this.linkSync(data, path.substr(1));
}

if (path[0] === '%') {
if (root) {
type = 'directory';
info = {
paths: {}
};

} else if (path[0] === '%') {
type = 'symlink';
path = path.substr(1);
info = {
Expand Down
9 changes: 9 additions & 0 deletions test/fs.posix.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
expect(fs.statSync('/home/john/passwords.txt').isFile()).to.be.true;
});

// @see https://github.com/sakren/node-fs-mock/issues/15
it('should create root directory', function() {
fs = new FS({
'var/www/index.php': ''
});

expect(fs.statSync('/').isDirectory()).to.be.true;
});

});


Expand Down

0 comments on commit d01f06e

Please sign in to comment.