Skip to content
This repository has been archived by the owner on Jun 22, 2019. It is now read-only.

Commit

Permalink
Linted sources. Fix some typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Dec 19, 2012
1 parent 61614f1 commit 46a8580
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 24 deletions.
35 changes: 14 additions & 21 deletions lib/fs-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ fstools.remove = function (path, callback) {
async.series([
async.apply(walk_flat, path, fstools.remove),
async.apply(fs.rmdir, path)
], function (err, results) {
], function (err/*, results */) {
callback(err);
});
});
Expand Down Expand Up @@ -576,31 +576,24 @@ fstools.copy = function (src, dst, callback) {
* Moves file from `source` to `destination`.
**/
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);
});
});
};
Expand Down
2 changes: 2 additions & 0 deletions test/copy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require('vows').describe('copy()').addBatch({
});
},
'should just work': function (err, dst) {
dst = dst; // ugly workaround for jshint + vows
Assert.ok(!err, 'Has no errror');
},
'creates directory fuu': function (err, dst) {
Expand Down Expand Up @@ -78,6 +79,7 @@ require('vows').describe('copy()').addBatch({
'links are overwriten': 'TBD',

'directories are merged': function (err) {
err = err; // ugly workaround for jshint + vows
Assert.pathExists(SANDBOX + '/foo/baz');
Assert.isDirectory(Fs.statSync(SANDBOX + '/foo/baz'));
}
Expand Down
1 change: 0 additions & 1 deletion test/find-sorted-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var SANDBOX = Helper.SANDBOX_DIR + '/find-sorted';
require('vows').describe('findSorted()').addBatch({
'found files in deirectory': {
topic: function () {
var cb = this.callback;
FsTools.findSorted(SANDBOX, this.callback);
},

Expand Down
1 change: 0 additions & 1 deletion test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


var Fs = require('fs');
var Path = require('path');
var Assert = require('assert');
var Helper = module.exports = {};

Expand Down
1 change: 1 addition & 0 deletions test/mkdir-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ require('vows').describe('mkdir()').addBatch({
FsTools.mkdir('/FOOBAR-FS-TOOLS', this.callback);
},
'can\'t create under /etc': function (err, result) {
result = result; // ugly workaround for jshint + vows
Assert.instanceOf(err, Error);
Assert.equal(err.code, 'EACCES');
}
Expand Down
3 changes: 3 additions & 0 deletions test/move-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require('vows').describe('move()').addBatch({
});
},
'should just work': function (err, dst) {
dst = dst; // ugly workaround for jshint + vows
Assert.ok(!err, 'Has no errror');
},
'creates directory fuu': function (err, dst) {
Expand All @@ -35,6 +36,7 @@ require('vows').describe('move()').addBatch({
Assert.isDirectory(Fs.statSync(dst + '/bar/baz/link'));
},
'removes foo': function (err, dst) {
dst = dst; // ugly workaround for jshint + vows
Assert.pathNotExists(SANDBOX + '/foo');
},
'after all': {
Expand Down Expand Up @@ -83,6 +85,7 @@ require('vows').describe('move()').addBatch({
'links are overwriten': 'TBD',

'directories are merged': function (err) {
err = err; // ugly workaround for jshint + vows
Assert.pathExists(SANDBOX + '/foo/baz');
Assert.isDirectory(Fs.statSync(SANDBOX + '/foo/baz'));
}
Expand Down
1 change: 0 additions & 1 deletion test/tmpdir-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


var FsTools = require('../');
var Helper = require('./helper');
var Assert = require('assert');

require('vows').describe('tmpdir()').addBatch({
Expand Down
1 change: 1 addition & 0 deletions test/walk-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ require('vows').describe('walk()').addBatch({
});
},
'finishes without errors': function (err, result) {
result = result; // ugly workaround for jshint + vows
Assert.ok(!err, 'Has no errors');
},
'calls iterator on all entries': function (err, result) {
Expand Down

0 comments on commit 46a8580

Please sign in to comment.