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

Commit

Permalink
Merge branch 'master' of github.com:ryanmcgrath/wrench-js
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan McGrath committed May 16, 2012
2 parents 5adf506 + b035bdc commit d1ffccb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
npm-debug.log
4 changes: 2 additions & 2 deletions lib/wrench.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exports.readdirSyncRecursive = function(baseDir) {

// convert absolute paths to relative
var fileList = readdirSyncRecursive(baseDir).map(function(val){
return val.replace(baseDir + '/', '');
return _path.relative(baseDir, val);
});

return fileList;
Expand Down Expand Up @@ -106,7 +106,7 @@ exports.readdirRecursive = function(baseDir, fn) {

fn(null, curFiles.map(function(val) {
// convert absolute paths to relative
return val.replace(baseDir + '/', '');
return _path.relative(baseDir, val);
}));

if (waitCount == 0) {
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
},

"devDependencies": {
"nodeunit": ">= 0.6.4",
"underscore": ">= 1.3.1"
"nodeunit": ">= 0.6.4"
},

"main": "./lib/wrench",
Expand All @@ -31,7 +30,7 @@
"node": ">=0.1.97"
},

"scripts": { "test": "./node_modules/nodeunit/bin/nodeunit tests/runner.js" },
"scripts": { "test": "nodeunit tests/runner.js" },

"licenses": [{
"type" : "MIT",
Expand Down
19 changes: 7 additions & 12 deletions tests/readdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,26 @@ var testCase = require('nodeunit').testCase;
var fs = require('fs');
var wrench = require('../lib/wrench');
var path = require('path');
var _und = require("underscore");


function checkResult(test, files) {
var check = [
'bar.txt',
'foo',
'foo/bar',
'foo/dolor.md',
'foo/lorem.txt',
'foo/bar/ipsum.js'
path.join('foo', 'bar'),
path.join('foo', 'dolor.md'),
path.join('foo', 'lorem.txt'),
path.join('foo', 'bar', 'ipsum.js')
];

test.equals(files.length, check.length, 'number of paths is correct');

_und.each(check, function(it) {
test.ok(_und.include(files, it), 'path ' + it + ' should be returned');
});
test.deepEqual(files, check);

test.done();
}

module.exports = testCase({
test_readdirSyncRecursive: function(test) {
var dir = __dirname + '/readdir';
var dir = path.join(__dirname, 'readdir');

test.ok(path.existsSync(dir), 'Folders should exist');

Expand All @@ -36,7 +31,7 @@ module.exports = testCase({
},

test_readdirRecursive: function(test) {
var dir = __dirname + '/readdir';
var dir = path.join(__dirname, 'readdir');

test.ok(path.existsSync(dir), 'Folders should exist');

Expand Down

0 comments on commit d1ffccb

Please sign in to comment.