From 2abdfaf40c2d7ece8184ac6d2e10573995c2d4a6 Mon Sep 17 00:00:00 2001 From: domenic Date: Mon, 14 May 2012 19:14:16 -0400 Subject: [PATCH 1/5] Add npm-debug.log to .gitignore. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 99342e073f1a7231adc3f21cc8af7f3dd1686125 Mon Sep 17 00:00:00 2001 From: domenic Date: Mon, 14 May 2012 19:15:28 -0400 Subject: [PATCH 2/5] Updating test script to work on Windows. npm had a bug a while ago where you needed to specify the full path for scripts. This is no longer the case. Using the command name instead of the full path allows `npm test` to work on Windows. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1e7eb15..424e6ea 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "node": ">=0.1.97" }, - "scripts": { "test": "./node_modules/nodeunit/bin/nodeunit tests/runner.js" }, + "scripts": { "test": "nodeunit tests/runner.js" }, "licenses": [{ "type" : "MIT", From 828798c43c40725853db7c310beaf06fa6930e85 Mon Sep 17 00:00:00 2001 From: domenic Date: Mon, 14 May 2012 19:21:37 -0400 Subject: [PATCH 3/5] Using nodeunit's deepEqual instead of manually looping. This makes for more readable assertion messages (so you can actually see the difference in the lists), and removes the underscore dependency. --- package.json | 3 +-- tests/readdir.js | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 424e6ea..4cc9362 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", diff --git a/tests/readdir.js b/tests/readdir.js index b2d14f0..bca8ad6 100644 --- a/tests/readdir.js +++ b/tests/readdir.js @@ -2,7 +2,6 @@ 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) { @@ -15,11 +14,7 @@ function checkResult(test, files) { '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(); } From 01190602dac64924fca2dae11912ffb560e636a0 Mon Sep 17 00:00:00 2001 From: domenic Date: Mon, 14 May 2012 19:27:13 -0400 Subject: [PATCH 4/5] Use `path.relative` instead of manual string replacement. Fixes Windows inconsistency (#26). --- lib/wrench.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) { From 5d1d96379b503a5600798b2a311eb89c1ab54a70 Mon Sep 17 00:00:00 2001 From: domenic Date: Mon, 14 May 2012 19:30:39 -0400 Subject: [PATCH 5/5] Fixing tests to use `path.join` for Windows compat. Now they pass on Windows. --- tests/readdir.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/readdir.js b/tests/readdir.js index b2d14f0..773e717 100644 --- a/tests/readdir.js +++ b/tests/readdir.js @@ -9,10 +9,10 @@ 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'); @@ -26,7 +26,7 @@ function checkResult(test, files) { 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 +36,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');