From 754f6bb9c4ad16e23419c2c475d5438c90c4fd97 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 26 Jan 2014 19:08:15 -0700 Subject: [PATCH] allow providing a directory, mark as file or directory --- test/test-walk.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/test-walk.js b/test/test-walk.js index 6868879..540ecc4 100644 --- a/test/test-walk.js +++ b/test/test-walk.js @@ -2,13 +2,24 @@ "use strict"; var walk = require('../lib/walk').walk + , path = require('path') + , dirname = process.argv[2] || './' , walker ; - walker = walk('./'); - walker.on('file', function (root, stat, next) { - console.log(root, stat.name); + walker = walk(dirname); + + walker.on('directory', function (root, stat, next) { + console.log('[d]', path.join(root, stat.name)); next(); }); + walker.on('file', function (root, stat, next) { + console.log('[f]', path.join(root, stat.name)); + next(); + }); + + walker.on('end', function () { + console.log('All Done!'); + }); }());