Skip to content

Commit e232d46

Browse files
authored
Fix for Node Path instance not being sent to onEachFile and onEachDirectory callbacks
The README says: "The callback function takes the directory item (has path, name, size, and extension) and an instance of [node path](https://nodejs.org/api/path.html) and an instance of [node FS.stats](https://nodejs.org/api/fs.html#fs_class_fs_stats)." However, the callbacks are not sent the Node Path instance but instead are sent the `path` variable. Changing from `path` to `PATH` fixes it to work as described in the README.
1 parent df588ae commit e232d46

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/directory-tree.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function directoryTree (path, options, onEachFile, onEachDirectory) {
8484
}
8585

8686
if (onEachFile) {
87-
onEachFile(item, path, stats);
87+
onEachFile(item, PATH, stats);
8888
}
8989
}
9090
else if (stats.isDirectory()) {
@@ -102,7 +102,7 @@ function directoryTree (path, options, onEachFile, onEachDirectory) {
102102
item.size = item.children.reduce((prev, cur) => prev + cur.size, 0);
103103
item.type = constants.DIRECTORY;
104104
if (onEachDirectory) {
105-
onEachDirectory(item, path, stats);
105+
onEachDirectory(item, PATH, stats);
106106
}
107107
} else {
108108
return null; // Or set item.size = 0 for devices, FIFO and sockets ?

0 commit comments

Comments
 (0)