Comparing version 0.1.2 to 0.1.3
@@ -9,3 +9,3 @@ /** | ||
* | ||
* @version 0.1.2 | ||
* @version 0.1.3 | ||
*/ | ||
@@ -29,3 +29,4 @@ | ||
makeDir = promisify(fs.mkdir), | ||
removeDir = promisify(fs.rmdir); | ||
removeDir = promisify(fs.rmdir), | ||
undef; | ||
@@ -205,5 +206,11 @@ module.exports = { | ||
* @param [mode=0777] | ||
* @param [failIfExist=false] | ||
* @returns {Vow.promise} | ||
*/ | ||
makeDir : function(dirPath, mode) { | ||
makeDir : function(dirPath, mode, failIfExist) { | ||
if(typeof mode === 'boolean') { | ||
failIfExist = mode; | ||
mode = undef; | ||
} | ||
var _this = this, | ||
@@ -214,3 +221,13 @@ dirName = path.dirname(dirPath); | ||
return exists? | ||
makeDir(dirPath, mode) : | ||
makeDir(dirPath, mode).fail(function(e) { | ||
if(e.code !== 'EEXIST' || failIfExist) { | ||
throw e; | ||
} | ||
return _this.isDir(dirPath).then(function(isDir) { | ||
if(!isDir) { | ||
throw e; | ||
} | ||
}); | ||
}) : | ||
_this.makeDir(dirName, mode).then(function() { | ||
@@ -217,0 +234,0 @@ return makeDir(dirPath, mode); |
{ | ||
"name" : "vow-fs", | ||
"version" : "0.1.2", | ||
"version" : "0.1.3", | ||
"description" : "File I/O by Vow", | ||
@@ -5,0 +5,0 @@ "homepage" : "https://github.com/dfilatov/vow-fs", |
var fs = require('./lib/fs'), | ||
path = require('path'); | ||
fs.removeDir('a').then(function(ex) { | ||
fs.makeDir('package.json').then(function(ex) { | ||
console.log('!'); | ||
@@ -6,0 +6,0 @@ }, function(err) { |
8642
238