resolve relative paths, add two test cases
This commit is contained in:
parent
4aae53839a
commit
f1fc53d88f
|
@ -387,7 +387,8 @@ Shell.prototype.mkdirp = function(path, callback) {
|
|||
callback(new Errors.EINVAL('Missing path argument'));
|
||||
return;
|
||||
}
|
||||
else if (path === '/') {
|
||||
path = Path.resolve(sh.pwd(), path);
|
||||
if (path === '/') {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,18 @@ describe('FileSystemShell.mkdirp', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should succeed if provided path is root, given as a relative path (\'.\' in \'/\')', function(done) {
|
||||
var fs = util.fs();
|
||||
var shell = new fs.Shell();
|
||||
shell.cd('/', function(err) {
|
||||
expect(err).to.not.exist;
|
||||
shell.mkdirp('.', function(err) {
|
||||
expect(err).to.not.exist;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should succeed if the directory exists', function(done) {
|
||||
var fs = util.fs();
|
||||
var shell = new fs.Shell();
|
||||
|
@ -67,6 +79,21 @@ describe('FileSystemShell.mkdirp', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should succeed on a folder given as a relative path (\'test\' in \'/\')', function(done) {
|
||||
var fs = util.fs();
|
||||
var shell = new fs.Shell();
|
||||
shell.cd('/', function(err) {
|
||||
expect(err).to.not.exist;
|
||||
shell.mkdirp('test', function(err) {
|
||||
expect(err).to.not.exist;
|
||||
fs.exists('/test', function(dir){
|
||||
expect(dir).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should succeed on a folder with a nonexistant parent (\'/test/test\')', function(done) {
|
||||
var fs = util.fs();
|
||||
var shell = new fs.Shell();
|
||||
|
|
Loading…
Reference in New Issue