Comparing version 0.2.6 to 0.2.7
@@ -0,1 +1,7 @@ | ||
0.2.7 / 2012-12-19 | ||
------------------ | ||
* Added FsTools.mkdirSync() | ||
0.2.6 / 2012-10-15 | ||
@@ -2,0 +8,0 @@ ------------------ |
@@ -311,3 +311,3 @@ /** | ||
async.apply(fs.rmdir, path) | ||
], function (err, results) { | ||
], function (err/*, results */) { | ||
callback(err); | ||
@@ -435,2 +435,27 @@ }); | ||
/** | ||
* FsTools.mkdirSync(path[, mode = '0755']) -> void | ||
* | ||
* Sync version of [[FsTools.mkdir]]. | ||
**/ | ||
fstools.mkdirSync = function (path, mode) { | ||
mode = mode || '0755'; | ||
path = path_normalize(path); | ||
if (fs.existsSync(path)) { | ||
return; | ||
} | ||
fstools.mkdirSync(dirname(path), mode); | ||
try { | ||
fs.mkdirSync(path, mode); | ||
} catch (err) { | ||
if ('EEXIST' !== err.code) { | ||
throw err; | ||
} | ||
} | ||
}; | ||
/** | ||
* FsTools.copy(src, dst, callback) -> void | ||
@@ -556,27 +581,20 @@ * - src (String): Source file | ||
fstools.move = function move(source, destination, callback) { | ||
fs.lstat(source, function (err, stats) { | ||
if (err) { | ||
callback(err); | ||
fs.rename(source, destination, function (err) { | ||
if (!err) { | ||
callback(); | ||
return; | ||
} | ||
fs.rename(source, destination, function (err) { | ||
if (!err) { | ||
callback(); | ||
return; | ||
} | ||
// TODO: Needs testing coverage | ||
// TODO: Needs testing coverage | ||
// normally err.code can be: | ||
// - EXDEV (different partitions/devices) | ||
// - ENOTEMPTY (source and destination are not-empty dirs) | ||
// - EISDIR (destionation is dir, source is file) | ||
// normally err.code can be: | ||
// - EXDEV (different partitions/devices) | ||
// - ENOTEMPTY (source and destination are not-empty dirs) | ||
// - EISDIR (destionation is dir, source is file) | ||
async.series([ | ||
async.apply(fstools.copy, source, destination), | ||
async.apply(fstools.remove, source) | ||
], function (err/*, results*/) { | ||
callback(); | ||
}); | ||
async.series([ | ||
async.apply(fstools.copy, source, destination), | ||
async.apply(fstools.remove, source) | ||
], function (err/*, results*/) { | ||
callback(err); | ||
}); | ||
@@ -583,0 +601,0 @@ }); |
{ | ||
"name" : "fs-tools", | ||
"version" : "0.2.6", | ||
"version" : "0.2.7", | ||
"description" : "fs helper utilities (walk, copy, mkdir -p)", | ||
@@ -5,0 +5,0 @@ "keywords" : ["fs", "file", "utils"], |
@@ -21,2 +21,3 @@ 'use strict'; | ||
'should just work': function (err, dst) { | ||
dst = dst; // ugly workaround for jshint + vows | ||
Assert.ok(!err, 'Has no errror'); | ||
@@ -82,2 +83,3 @@ }, | ||
'directories are merged': function (err) { | ||
err = err; // ugly workaround for jshint + vows | ||
Assert.pathExists(SANDBOX + '/foo/baz'); | ||
@@ -84,0 +86,0 @@ Assert.isDirectory(Fs.statSync(SANDBOX + '/foo/baz')); |
@@ -13,3 +13,2 @@ 'use strict'; | ||
topic: function () { | ||
var cb = this.callback; | ||
FsTools.findSorted(SANDBOX, this.callback); | ||
@@ -16,0 +15,0 @@ }, |
@@ -5,3 +5,2 @@ 'use strict'; | ||
var Fs = require('fs'); | ||
var Path = require('path'); | ||
var Assert = require('assert'); | ||
@@ -8,0 +7,0 @@ var Helper = module.exports = {}; |
@@ -35,2 +35,3 @@ 'use strict'; | ||
'can\'t create under /etc': function (err, result) { | ||
result = result; // ugly workaround for jshint + vows | ||
Assert.instanceOf(err, Error); | ||
@@ -37,0 +38,0 @@ Assert.equal(err.code, 'EACCES'); |
@@ -23,2 +23,3 @@ 'use strict'; | ||
'should just work': function (err, dst) { | ||
dst = dst; // ugly workaround for jshint + vows | ||
Assert.ok(!err, 'Has no errror'); | ||
@@ -39,2 +40,3 @@ }, | ||
'removes foo': function (err, dst) { | ||
dst = dst; // ugly workaround for jshint + vows | ||
Assert.pathNotExists(SANDBOX + '/foo'); | ||
@@ -88,2 +90,3 @@ }, | ||
'directories are merged': function (err) { | ||
err = err; // ugly workaround for jshint + vows | ||
Assert.pathExists(SANDBOX + '/foo/baz'); | ||
@@ -90,0 +93,0 @@ Assert.isDirectory(Fs.statSync(SANDBOX + '/foo/baz')); |
@@ -5,3 +5,2 @@ 'use strict'; | ||
var FsTools = require('../'); | ||
var Helper = require('./helper'); | ||
var Assert = require('assert'); | ||
@@ -8,0 +7,0 @@ |
@@ -33,2 +33,3 @@ 'use strict'; | ||
'finishes without errors': function (err, result) { | ||
result = result; // ugly workaround for jshint + vows | ||
Assert.ok(!err, 'Has no errors'); | ||
@@ -35,0 +36,0 @@ }, |
Sorry, the diff of this file is not supported yet
46632
26
1100
11