# traverseDirectory

`function` in `utils` · v0.4.0

<https://docs.seedcord.org/packages/utils/0.4.0/functions/traverse-directory>

Recursively traverses through a directory, importing all .ts and .js files and applying a callback to each import.

```ts
async traverseDirectory(
    dir: string,
    callback: (
        fullPath: string,
        relativePath: string,
        imported: Record<string, unknown>
    ) => Promise<void> | void,
    logger: ILogger
): Promise<void>
```

Recursively traverses through a directory, importing all .ts and .js files and applying a callback to each import.

Parameters.

- `dir` `string` — The directory path to traverse.
- `callback` `(fullPath: string, relativePath: string, imported: Record<string, unknown>) => Promise<void> | void` — A function that will be called for each imported module. It receives the full file path, the file's relative path, and the imported module as arguments.
- `logger` `ILogger`

Returns `Promise<void>`.
