File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change 1
- var fs = require ( 'fs' ) ;
1
+ var fs = require ( 'fs' ) ,
2
+ path = require ( 'path' ) ;
2
3
3
4
module . exports . walk = function ( dir , opts ) {
4
5
@@ -22,20 +23,17 @@ module.exports.walk = function (dir, opts) {
22
23
23
24
var stat ;
24
25
25
- file = ( dir + '/' + file ) . replace ( / \/ + / g , '/' ) ;
26
+ file = path . normalize ( dir + '/' + file ) ;
26
27
27
28
stat = fs . statSync ( file ) ;
28
29
29
- if ( stat . isFile ( ) &&
30
- file . match ( opts . match ) &&
31
- ! file . match ( opts . exception ) ) {
30
+ if ( stat . isDirectory ( ) && ! file . match ( opts . exception ) ) {
32
31
33
- files . push ( file ) ;
32
+ files = files . concat ( module . exports . walk ( file , opts ) ) ;
34
33
35
- } else if ( stat . isDirectory ( ) &&
36
- ! file . match ( opts . exception ) ) {
34
+ } else if ( stat . isFile ( ) && file . match ( opts . match ) && ! file . match ( opts . exception ) ) {
37
35
38
- files = files . concat ( module . exports . walk ( file + '/' , opts ) ) ;
36
+ files . push ( file ) ;
39
37
40
38
}
41
39
You can’t perform that action at this time.
0 commit comments