Comparing version 0.1.6 to 0.1.7
@@ -9,3 +9,3 @@ /** | ||
* | ||
* @version 0.1.6 | ||
* @version 0.1.7 | ||
*/ | ||
@@ -12,0 +12,0 @@ |
43
make.js
@@ -1,33 +0,20 @@ | ||
var vfs = require('./lib/fs'), | ||
Vow = require('./node_modules/vow/lib/vow'), | ||
ps = []; | ||
var q = require('q'), | ||
Vow = require('./node_modules/vow/lib/vow'); | ||
vfs.makeDir('dir').then(function() { | ||
(function() { | ||
var d = q.defer(); | ||
for(var i = 0; i < 1000; i++) { | ||
ps.push(vfs.copy('package.json', 'dir/package' + i + '.json')); | ||
} | ||
d.reject(Error('oh')); | ||
Vow.all(ps).then( | ||
function() { | ||
var t1 = Date.now(); | ||
d.promise.fail(function(e) { | ||
throw Error('oh'); | ||
}) | ||
}); | ||
ps = []; | ||
for(var i = 0; i < 1000; i++) { | ||
ps.push(vfs.remove('dir/package' + i + '.json')); | ||
} | ||
(function() { | ||
var d = Vow.promise(); | ||
Vow.all(ps).then( | ||
function() { | ||
var d = Date.now() - t1; | ||
console.log(d); | ||
vfs.remove('dir'); | ||
}, | ||
function(err) { | ||
console.error(err); | ||
}); | ||
}, | ||
function(err) { | ||
console.error(err); | ||
}); | ||
}); | ||
d.reject(Error('oh')); | ||
d.done(); | ||
})(); |
{ | ||
"name" : "vow-fs", | ||
"version" : "0.1.6", | ||
"version" : "0.1.7", | ||
"description" : "File I/O by Vow", | ||
@@ -18,6 +18,6 @@ "homepage" : "https://github.com/dfilatov/vow-fs", | ||
"peerDependencies": { | ||
"vow" : "0.1.x" | ||
"vow" : ">= 0.1.x" | ||
}, | ||
"devDependencies": { | ||
"vow" : "0.1.x", | ||
"vow" : ">= 0.1.x", | ||
"nodeunit" : "", | ||
@@ -24,0 +24,0 @@ "istanbul" : "" |
@@ -99,4 +99,4 @@ var fs = require('fs'), | ||
test.done(); | ||
}) | ||
}); | ||
} | ||
}; |
@@ -19,8 +19,16 @@ var fs = require('fs'), | ||
var dir = path.join(TEST_DIR, 'a'); | ||
vfs.makeDir(dir).then(function() { | ||
test.ok(fs.existsSync(dir)); | ||
test.ok(fs.statSync(dir).isDirectory()); | ||
fs.rmdirSync(dir); | ||
test.done(); | ||
}); | ||
vfs.makeDir(dir) | ||
.then( | ||
function() { | ||
return vfs.exists(dir); | ||
}, | ||
function() { | ||
test.ok(false); | ||
}) | ||
.always(function(promise) { | ||
test.ok(promise.valueOf()); | ||
test.ok(fs.statSync(dir).isDirectory()); | ||
fs.rmdirSync(dir); | ||
test.done(); | ||
}); | ||
}, | ||
@@ -31,8 +39,16 @@ | ||
fs.mkdirSync(dir); | ||
vfs.makeDir(dir).then(function() { | ||
test.ok(fs.existsSync(dir)); | ||
test.ok(fs.statSync(dir).isDirectory()); | ||
fs.rmdirSync(dir); | ||
test.done(); | ||
}); | ||
vfs.makeDir(dir) | ||
.then( | ||
function() { | ||
return vfs.exists(dir); | ||
}, | ||
function() { | ||
test.ok(false); | ||
}) | ||
.always(function(promise) { | ||
test.ok(promise.valueOf()); | ||
test.ok(fs.statSync(dir).isDirectory()); | ||
fs.rmdirSync(dir); | ||
test.done(); | ||
}); | ||
}, | ||
@@ -43,6 +59,14 @@ | ||
fs.mkdirSync(dir); | ||
vfs.makeDir(dir, true).fail(function() { | ||
fs.rmdirSync(dir); | ||
test.done(); | ||
}); | ||
vfs.makeDir(dir, true) | ||
.then( | ||
function() { | ||
test.ok(false); | ||
}, | ||
function() { | ||
test.ok(true); | ||
fs.rmdirSync(dir); | ||
}) | ||
.always(function() { | ||
test.done(); | ||
}); | ||
}, | ||
@@ -53,6 +77,14 @@ | ||
fs.writeFileSync(dir, 'test'); | ||
vfs.makeDir(dir).fail(function() { | ||
fs.unlink(path.join(TEST_DIR, 'test-file')); | ||
test.done(); | ||
}); | ||
vfs.makeDir(dir) | ||
.then( | ||
function() { | ||
test.ok(false); | ||
}, | ||
function() { | ||
test.ok(true); | ||
fs.unlink(path.join(TEST_DIR, 'test-file')); | ||
}) | ||
.always(function() { | ||
test.done(); | ||
}); | ||
}, | ||
@@ -62,10 +94,18 @@ | ||
var dir = path.join(TEST_DIR, 'a/b/c'); | ||
vfs.makeDir(dir).then(function() { | ||
test.ok(fs.existsSync(dir)); | ||
test.ok(fs.statSync(dir).isDirectory()); | ||
fs.rmdirSync(path.join(TEST_DIR, 'a/b/c')); | ||
fs.rmdirSync(path.join(TEST_DIR, 'a/b')); | ||
fs.rmdirSync(path.join(TEST_DIR, 'a')); | ||
test.done(); | ||
}); | ||
vfs.makeDir(dir) | ||
.then( | ||
function() { | ||
return vfs.exists(dir); | ||
}, | ||
function() { | ||
test.ok(false); | ||
}) | ||
.always(function(promise) { | ||
test.ok(promise.valueOf()); | ||
test.ok(fs.statSync(dir).isDirectory()); | ||
fs.rmdirSync(path.join(TEST_DIR, 'a/b/c')); | ||
fs.rmdirSync(path.join(TEST_DIR, 'a/b')); | ||
fs.rmdirSync(path.join(TEST_DIR, 'a')); | ||
test.done(); | ||
}); | ||
}, | ||
@@ -78,9 +118,17 @@ | ||
fs.mkdirSync(dir); | ||
vfs.makeDir(dir).then(function() { | ||
fs.rmdirSync(path.join(TEST_DIR, 'a/b/c')); | ||
fs.rmdirSync(path.join(TEST_DIR, 'a/b')); | ||
fs.rmdirSync(path.join(TEST_DIR, 'a')); | ||
test.done(); | ||
}); | ||
vfs.makeDir(dir) | ||
.then( | ||
function() { | ||
fs.rmdirSync(path.join(TEST_DIR, 'a/b/c')); | ||
fs.rmdirSync(path.join(TEST_DIR, 'a/b')); | ||
fs.rmdirSync(path.join(TEST_DIR, 'a')); | ||
test.ok(true); | ||
}, | ||
function() { | ||
test.ok(false); | ||
}) | ||
.always(function() { | ||
test.done(); | ||
}); | ||
} | ||
}; |
@@ -20,6 +20,14 @@ var fs = require('fs'), | ||
fs.mkdirSync(dir); | ||
vfs.removeDir(dir).then(function() { | ||
test.ok(!fs.existsSync(dir)); | ||
test.done(); | ||
}); | ||
vfs.removeDir(dir) | ||
.then( | ||
function() { | ||
return vfs.exists(dir); | ||
}, | ||
function() { | ||
test.ok(false); | ||
}) | ||
.always(function(promise) { | ||
test.ok(!promise.valueOf()); | ||
test.done(); | ||
}); | ||
}, | ||
@@ -35,6 +43,14 @@ | ||
fs.writeFileSync(path.join(dir, 'a', 'b', 'file2'), 'file2'); | ||
vfs.removeDir(dir).then(function() { | ||
test.ok(!fs.existsSync(dir)); | ||
test.done(); | ||
}); | ||
vfs.removeDir(dir) | ||
.then( | ||
function() { | ||
return vfs.exists(dir); | ||
}, | ||
function() { | ||
test.ok(false); | ||
}) | ||
.always(function(promise) { | ||
test.ok(!promise.valueOf()); | ||
test.done(); | ||
}); | ||
}, | ||
@@ -45,9 +61,17 @@ | ||
fs.writeFileSync(filePath, 'file'); | ||
vfs.removeDir(filePath).fail(function(err) { | ||
test.equal(err.code, 'ENOTDIR'); | ||
test.ok(fs.existsSync(filePath)); | ||
fs.unlinkSync(filePath); | ||
test.done(); | ||
}); | ||
vfs.removeDir(filePath) | ||
.then( | ||
function() { | ||
test.ok(false); | ||
}, | ||
function(err) { | ||
test.equal(err.code, 'ENOTDIR'); | ||
return vfs.exists(filePath); | ||
}) | ||
.always(function(promise) { | ||
test.ok(promise.valueOf()); | ||
fs.unlinkSync(filePath); | ||
test.done(); | ||
}); | ||
} | ||
}; |
19462
555