File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -52,17 +52,24 @@ for (const type of apiTypes) {
52
52
includeBasePath : true ,
53
53
} ) . crawl ( "node_modules" ) ;
54
54
const files = await api [ type ] ( ) ;
55
- t . expect ( files . every ( ( file ) => file . split ( "/" ) . length <= 2 ) ) . toBe ( true ) ;
55
+ t . expect ( files ) . not . toHaveLength ( 0 ) ;
56
+ t . expect ( files . every ( ( file ) => file . split ( path . sep ) . length === 2 ) ) . toBe (
57
+ true
58
+ ) ;
56
59
} ) ;
57
60
58
61
test ( `[${ type } ] crawl multi depth directory with options` , async ( t ) => {
59
62
const api = new fdir ( {
60
63
maxDepth : 1 ,
64
+ includeBasePath : true ,
61
65
} ) . crawl ( "node_modules" ) ;
62
66
const files = await api [ type ] ( ) ;
63
- t . expect (
64
- files . every ( ( file ) => file . split ( path . sep ) . length <= 3 )
65
- ) . toBeTruthy ( ) ;
67
+ t . expect ( files . some ( ( file ) => file . split ( path . sep ) . length === 3 ) ) . toBe (
68
+ true
69
+ ) ;
70
+ t . expect ( files . every ( ( file ) => file . split ( path . sep ) . length <= 3 ) ) . toBe (
71
+ true
72
+ ) ;
66
73
} ) ;
67
74
68
75
test ( `[${ type } ] crawl multi depth directory` , async ( t ) => {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ const walkAsync: WalkDirectoryFunction = (
20
20
) => {
21
21
state . queue . enqueue ( ) ;
22
22
23
- if ( currentDepth <= 0 ) return state . queue . dequeue ( null , state ) ;
23
+ if ( currentDepth < 0 ) return state . queue . dequeue ( null , state ) ;
24
24
25
25
state . visited . push ( crawlPath ) ;
26
26
state . counts . directories ++ ;
@@ -41,7 +41,7 @@ const walkSync: WalkDirectoryFunction = (
41
41
currentDepth ,
42
42
callback
43
43
) => {
44
- if ( currentDepth <= 0 ) return ;
44
+ if ( currentDepth < 0 ) return ;
45
45
state . visited . push ( crawlPath ) ;
46
46
state . counts . directories ++ ;
47
47
You can’t perform that action at this time.
0 commit comments