Skip to content

Commit 700aaf4

Browse files
committed
Added path.normalize to utils.walk method.
Organized logic and cleaned up whitespace in utils.walk.
1 parent 2df6ef2 commit 700aaf4

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/utils.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
var fs = require('fs');
1+
var fs = require('fs'),
2+
path = require('path');
23

34
module.exports.walk = function (dir, opts) {
45

@@ -22,20 +23,17 @@ module.exports.walk = function (dir, opts) {
2223

2324
var stat;
2425

25-
file = (dir + '/' + file).replace(/\/+/g, '/');
26+
file = path.normalize(dir + '/' + file);
2627

2728
stat = fs.statSync(file);
2829

29-
if (stat.isFile() &&
30-
file.match(opts.match) &&
31-
!file.match(opts.exception)) {
30+
if (stat.isDirectory() && !file.match(opts.exception)) {
3231

33-
files.push(file);
32+
files = files.concat(module.exports.walk(file, opts));
3433

35-
} else if (stat.isDirectory() &&
36-
!file.match(opts.exception)) {
34+
} else if (stat.isFile() && file.match(opts.match) && !file.match(opts.exception)) {
3735

38-
files = files.concat(module.exports.walk(file + '/', opts));
36+
files.push(file);
3937

4038
}
4139

0 commit comments

Comments
 (0)