Repository: filerjs/filer (js)

Issue:
Shell.mkdirp does not support relative paths
exactly as the title says. trying it gives me `(EINVAL): Path must be absolute.`

As a workaround, replacing `path` by `Path.resolve(sh.pwd(), path)` works of course.

Pull request:
resolve relative paths in Shell.mkdirp()
Closes #755 

(I ran tests in Firefox only as I didn't have ChromeHeadless installed)

Patch:
diff --git a/src/shell/shell.js b/src/shell/shell.js
index 3704e1c..1ac0371 100644
--- a/src/shell/shell.js
+++ b/src/shell/shell.js
@@ -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;
   }


Test patch:
diff --git a/tests/spec/shell/mkdirp.spec.js b/tests/spec/shell/mkdirp.spec.js
index 5f88544..d25c466 100644
--- a/tests/spec/shell/mkdirp.spec.js
+++ b/tests/spec/shell/mkdirp.spec.js
@@ -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();