CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-fs-readdir-recursive

Recursively read a directory and return an array of all file paths

90

1.11x
Overview
Eval results
Files

task.mdevals/scenario-3/

Directory Scanner with Robust Error Handling

Build a directory analysis utility that safely scans directories and handles various edge cases gracefully, returning consistent results even when directories don't exist or are empty.

Capabilities

Safe Directory Scanning

The utility should scan directories and return file lists without throwing errors when encountering problematic paths.

  • When scanning a non-existent directory path, returns an empty array instead of throwing an error @test
  • When scanning an empty directory, returns an empty array @test
  • When scanning a directory with only subdirectories (no files), returns an empty array @test

Recursive File Discovery

The utility should recursively traverse directories to find all files.

  • When scanning a directory with nested subdirectories containing files, returns all file paths relative to the root @test

Implementation

@generates

API

/**
 * Scans a directory path and returns all file paths found.
 * Handles non-existent directories gracefully by returning an empty array.
 *
 * @param {string} dirPath - The directory path to scan
 * @returns {string[]} Array of relative file paths found, or empty array if directory doesn't exist
 */
function scanDirectory(dirPath) {
  // IMPLEMENTATION HERE
}

module.exports = { scanDirectory };

Dependencies { .dependencies }

fs-readdir-recursive { .dependency }

Provides recursive directory reading with built-in edge case handling.

Install with Tessl CLI

npx tessl i tessl/npm-fs-readdir-recursive

tile.json