1- import { afterAll , beforeAll , beforeEach , describe , test } from "vitest" ;
2- import { apiTypes , normalize , root } from "./utils" ;
1+ import { afterAll , beforeAll , describe , test } from "vitest" ;
2+ import { apiTypes , normalize , root , execute } from "./utils" ;
33import mock from "mock-fs" ;
4- import { fdir , Options } from "../src" ;
4+ import { fdir } from "../src" ;
55import path from "path" ;
66
77const fsWithRelativeSymlinks = {
@@ -154,7 +154,7 @@ for (const type of apiTypes) {
154154
155155 test ( `resolve symlinks` , async ( t ) => {
156156 const api = new fdir ( ) . withSymlinks ( ) . crawl ( "/some/dir" ) ;
157- const files = await api [ type ] ( ) ;
157+ const files = await execute ( api , type ) ;
158158 t . expect ( files . sort ( ) ) . toStrictEqual (
159159 normalize ( [
160160 "/other/dir/file-2" ,
@@ -166,7 +166,7 @@ for (const type of apiTypes) {
166166
167167 test ( `resolve recursive symlinks` , async ( t ) => {
168168 const api = new fdir ( ) . withSymlinks ( ) . crawl ( "/recursive" ) ;
169- const files = await api [ type ] ( ) ;
169+ const files = await execute ( api , type ) ;
170170 t . expect ( files . sort ( ) ) . toStrictEqual (
171171 normalize ( [
172172 "/double/recursive/another-file" ,
@@ -184,7 +184,7 @@ for (const type of apiTypes) {
184184 const api = new fdir ( )
185185 . withSymlinks ( { resolvePaths : false } )
186186 . crawl ( "/recursive" ) ;
187- const files = await api [ type ] ( ) ;
187+ const files = await execute ( api , type ) ;
188188 t . expect ( files . sort ( ) ) . toStrictEqual (
189189 normalize ( [
190190 "/recursive/dir/not-recursive/another-file" ,
@@ -234,7 +234,7 @@ for (const type of apiTypes) {
234234 . withRelativePaths ( )
235235 . withErrors ( )
236236 . crawl ( "./recursive" ) ;
237- const files = await api [ type ] ( ) ;
237+ const files = await execute ( api , type ) ;
238238 t . expect ( files . sort ( ) ) . toStrictEqual (
239239 normalize ( [
240240 "dir/not-recursive/another-file" ,
@@ -284,7 +284,7 @@ for (const type of apiTypes) {
284284 . withRelativePaths ( )
285285 . withErrors ( )
286286 . crawl ( "./recursive" ) ;
287- const files = await api [ type ] ( ) ;
287+ const files = await execute ( api , type ) ;
288288 t . expect ( files . sort ( ) ) . toStrictEqual (
289289 normalize ( [
290290 "..//double/recursive/another-file" ,
@@ -302,7 +302,7 @@ for (const type of apiTypes) {
302302 const api = new fdir ( )
303303 . withSymlinks ( { resolvePaths : false } )
304304 . crawl ( "/some/dir" ) ;
305- const files = await api [ type ] ( ) ;
305+ const files = await execute ( api , type ) ;
306306 t . expect ( files . sort ( ) ) . toStrictEqual (
307307 normalize ( [
308308 "/some/dir/dirSymlink/file-1" ,
@@ -317,7 +317,7 @@ for (const type of apiTypes) {
317317 . withSymlinks ( { resolvePaths : false } )
318318 . withRelativePaths ( )
319319 . crawl ( "/some/dir" ) ;
320- const files = await api [ type ] ( ) ;
320+ const files = await execute ( api , type ) ;
321321 t . expect ( files . sort ( ) ) . toStrictEqual (
322322 normalize ( [
323323 "dirSymlink/file-1" ,
@@ -332,7 +332,7 @@ for (const type of apiTypes) {
332332 . withSymlinks ( )
333333 . withRelativePaths ( )
334334 . crawl ( "./relative/dir" ) ;
335- const files = await api [ type ] ( ) ;
335+ const files = await execute ( api , type ) ;
336336 t . expect ( files . sort ( ) ) . toStrictEqual (
337337 normalize ( [
338338 "../../../../other-relative/dir/file-2" ,
@@ -347,7 +347,7 @@ for (const type of apiTypes) {
347347 . withSymlinks ( )
348348 . exclude ( ( _name , path ) => path === resolveSymlinkRoot ( "/sym/linked/" ) )
349349 . crawl ( "/some/dir" ) ;
350- const files = await api [ type ] ( ) ;
350+ const files = await execute ( api , type ) ;
351351 t . expect ( files . sort ( ) ) . toStrictEqual ( normalize ( [ "/other/dir/file-2" ] ) ) ;
352352 } ) ;
353353
@@ -358,31 +358,31 @@ for (const type of apiTypes) {
358358 ( _name , path ) => path === resolveSymlinkRoot ( "/some/dir/dirSymlink/" )
359359 )
360360 . crawl ( "/some/dir" ) ;
361- const files = await api [ type ] ( ) ;
361+ const files = await execute ( api , type ) ;
362362 t . expect ( files . sort ( ) ) . toStrictEqual (
363363 normalize ( [ "/some/dir/fileSymlink" ] )
364364 ) ;
365365 } ) ;
366366
367367 test ( `do not resolve symlinks` , async ( t ) => {
368368 const api = new fdir ( ) . crawl ( "/some/dir" ) ;
369- const files = await api [ type ] ( ) ;
369+ const files = await execute ( api , type ) ;
370370 t . expect ( files . sort ( ) ) . toStrictEqual (
371371 normalize ( [ "dirSymlink" , "fileSymlink" , "fileSymlink2" ] )
372372 ) ;
373373 } ) ;
374374
375375 test ( `exclude symlinks` , async ( t ) => {
376376 const api = new fdir ( { excludeSymlinks : true } ) . crawl ( "/some/dir" ) ;
377- const files = await api [ type ] ( ) ;
377+ const files = await execute ( api , type ) ;
378378 t . expect ( files ) . toHaveLength ( 0 ) ;
379379 } ) ;
380380
381381 test (
382382 "doesn't hang when resolving symlinks in the root directory" ,
383383 async ( t ) => {
384384 const api = new fdir ( ) . withSymlinks ( { resolvePaths : false } ) . crawl ( "/" ) ;
385- const files = await api [ type ] ( ) ;
385+ const files = await execute ( api , type ) ;
386386 const expectedFiles = normalize ( [ "/lib/file-1" , "/usr/lib/file-1" ] ) ;
387387 for ( const expectedFile of expectedFiles ) {
388388 t . expect ( files ) . toContain ( expectedFile ) ;
0 commit comments