UNPKG

368 BJavaScriptView Raw
1var fs = require('fs');
2var path = require('path');
3
4function travel(dir, callback) {
5 fs.readdirSync(dir).forEach(function (file) {
6 var pathname = path.join(dir, file);
7
8 if (fs.statSync(pathname).isDirectory()) {
9 travel(pathname, callback);
10 } else {
11 callback(pathname);
12 }
13 });
14}
15
16exports.travel = travel;