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-7/

Directory Inventory Tool

Build a simple command-line tool that creates an inventory of all non-hidden files in a directory tree. The tool should scan a specified directory recursively and generate a report listing all visible files.

Requirements

Your tool should accept a directory path as input and output a list of all files found, excluding any hidden files or directories (those starting with a dot). The output should show relative paths from the provided directory.

The tool must:

  • Recursively traverse the entire directory tree from the given starting point
  • Exclude hidden files and directories (those whose names start with '.')
  • Return paths relative to the starting directory
  • Handle cases where the directory doesn't exist gracefully (return empty result)

Implementation

@generates

API

/**
 * Creates an inventory of all non-hidden files in a directory tree.
 *
 * @param {string} dirPath - The directory path to scan
 * @returns {string[]} Array of relative file paths (excluding hidden files)
 */
function getInventory(dirPath) {
  // IMPLEMENTATION HERE
}

module.exports = { getInventory };

Test Cases

  • Given a directory with files 'readme.txt', '.hidden', 'src/app.js', '.git/config', returns ['readme.txt', 'src/app.js'] @test
  • Given a non-existent directory, returns an empty array @test
  • Given an empty directory, returns an empty array @test

Dependencies { .dependencies }

fs-readdir-recursive { .dependency }

Provides recursive directory reading support.

Install with Tessl CLI

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

tile.json