Skip to content

Commit 5c301b4

Browse files
committed
be consistent about target vs entry
1 parent c4e4894 commit 5c301b4

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

index.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,62 +43,62 @@ Walker.prototype.filterDir = function(fn) {
4343
/**
4444
* Process a file or directory.
4545
*/
46-
Walker.prototype.go = function(target) {
46+
Walker.prototype.go = function(entry) {
4747
var that = this
4848
this._pending++
4949

50-
fs.lstat(target, function(er, stat) {
50+
fs.lstat(entry, function(er, stat) {
5151
if (er) {
52-
that.emit('error', er, target, stat)
52+
that.emit('error', er, entry, stat)
5353
that.doneOne()
5454
return
5555
}
5656

5757
if (stat.isDirectory()) {
58-
if (!that._filterDir(target, stat)) {
58+
if (!that._filterDir(entry, stat)) {
5959
that.doneOne()
6060
} else {
61-
fs.readdir(target, function(er, files) {
61+
fs.readdir(entry, function(er, files) {
6262
if (er) {
63-
that.emit('error', er, target, stat)
63+
that.emit('error', er, entry, stat)
6464
that.doneOne()
6565
return
6666
}
6767

68-
that.emit('entry', target, stat)
69-
that.emit('dir', target, stat)
68+
that.emit('entry', entry, stat)
69+
that.emit('dir', entry, stat)
7070
files.forEach(function(part) {
71-
that.go(path.join(target, part))
71+
that.go(path.join(entry, part))
7272
})
7373
that.doneOne()
7474
})
7575
}
7676
} else if (stat.isSymbolicLink()) {
77-
that.emit('entry', target, stat)
78-
that.emit('symlink', target, stat)
77+
that.emit('entry', entry, stat)
78+
that.emit('symlink', entry, stat)
7979
that.doneOne()
8080
} else if (stat.isBlockDevice()) {
81-
that.emit('entry', target, stat)
82-
that.emit('blockDevice', target, stat)
81+
that.emit('entry', entry, stat)
82+
that.emit('blockDevice', entry, stat)
8383
that.doneOne()
8484
} else if (stat.isCharacterDevice()) {
85-
that.emit('entry', target, stat)
86-
that.emit('characterDevice', target, stat)
85+
that.emit('entry', entry, stat)
86+
that.emit('characterDevice', entry, stat)
8787
that.doneOne()
8888
} else if (stat.isFIFO()) {
89-
that.emit('entry', target, stat)
90-
that.emit('fifo', target, stat)
89+
that.emit('entry', entry, stat)
90+
that.emit('fifo', entry, stat)
9191
that.doneOne()
9292
} else if (stat.isSocket()) {
93-
that.emit('entry', target, stat)
94-
that.emit('socket', target, stat)
93+
that.emit('entry', entry, stat)
94+
that.emit('socket', entry, stat)
9595
that.doneOne()
9696
} else if (stat.isFile()) {
97-
that.emit('entry', target, stat)
98-
that.emit('file', target, stat)
97+
that.emit('entry', entry, stat)
98+
that.emit('file', entry, stat)
9999
that.doneOne()
100100
} else {
101-
that.emit('error', UnknownFileTypeError(), target, stat)
101+
that.emit('error', UnknownFileTypeError(), entry, stat)
102102
that.doneOne()
103103
}
104104
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "walker",
33
"description": "A simple directory tree walker.",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"author": "Naitik Shah <n@daaku.org>",
66
"keywords": ["utils", "fs", "filesystem"],
77
"main": "index",

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ directory trees. This shows the entire API; everything is optional:
3737
.on('characterDevice', function(characterDevice, stat) {
3838
console.log('Got characterDevice: ' + characterDevice)
3939
})
40-
.on('error', function(er, target, stat) {
41-
console.log('Got error ' + er + ' on target ' + target)
40+
.on('error', function(er, entry, stat) {
41+
console.log('Got error ' + er + ' on entry ' + entry)
4242
})
4343
.on('end', function() {
4444
console.log('All files traversed.')

test/walker.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exports['simple walk'] = function(beforeExit) {
3434
file, 'Unexpected file.')
3535
n--
3636
})
37-
.on('error', function(er, target, stat) {
37+
.on('error', function(er, entry, stat) {
3838
assert.ifError(er)
3939
})
4040
.on('end', function() {
@@ -65,7 +65,7 @@ exports['simple walk, exclude sub-directory tree'] = function(beforeExit) {
6565
file, 'Unexpected file.')
6666
n--
6767
})
68-
.on('error', function(er, target, stat) {
68+
.on('error', function(er, entry, stat) {
6969
assert.ifError(er)
7070
})
7171
.on('end', function() {
@@ -93,8 +93,8 @@ exports['error walk'] = function(beforeExit) {
9393
file, 'Unexpected file.')
9494
n--
9595
})
96-
.on('error', function(er, target, stat) {
97-
assert.equal(ERROR_WALK + '/d', target, 'Expect specific error.')
96+
.on('error', function(er, entry, stat) {
97+
assert.equal(ERROR_WALK + '/d', entry, 'Expect specific error.')
9898
n--
9999
})
100100
.on('end', function() {
@@ -116,8 +116,8 @@ exports['bad start'] = function(beforeExit) {
116116
.on('file', function(file) {
117117
n--
118118
})
119-
.on('error', function(er, target, stat) {
120-
assert.equal(BAD_START_WALK, target, 'Expect specific error.')
119+
.on('error', function(er, entry, stat) {
120+
assert.equal(BAD_START_WALK, entry, 'Expect specific error.')
121121
n--
122122
})
123123
.on('end', function() {
@@ -163,7 +163,7 @@ exports['symlink test'] = function(beforeExit) {
163163
)
164164
n--
165165
})
166-
.on('error', function(er, target, stat) {
166+
.on('error', function(er, entry, stat) {
167167
assert.ifError(er)
168168
})
169169
.on('end', function() {

0 commit comments

Comments
 (0)