diff --git a/.gitignore b/.gitignore index b512c09..93f1361 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +npm-debug.log diff --git a/lib/wrench.js b/lib/wrench.js index 07386f8..00f4166 100644 --- a/lib/wrench.js +++ b/lib/wrench.js @@ -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; @@ -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) { diff --git a/package.json b/package.json index 5a0b5a2..09ee58e 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,7 @@ }, "devDependencies": { - "nodeunit": ">= 0.6.4", - "underscore": ">= 1.3.1" + "nodeunit": ">= 0.6.4" }, "main": "./lib/wrench", @@ -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", diff --git a/tests/readdir.js b/tests/readdir.js index b2d14f0..c314229 100644 --- a/tests/readdir.js +++ b/tests/readdir.js @@ -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'); @@ -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');