Recursively read a directory and return an array of all file paths
90
Build a utility that scans a directory tree and categorizes all discovered items by type, with proper handling of symbolic links.
Your solution should provide a function that recursively scans a directory and returns an object containing three arrays:
The function should:
@generates
/**
* Scans a directory tree and categorizes items by type.
*
* @param {string} rootDir - The root directory to scan
* @returns {Object} An object with three arrays: files, directories, and brokenLinks
* @returns {string[]} returns.files - Array of relative paths to regular files (including symlinked files)
* @returns {string[]} returns.directories - Array of relative paths to directories (including symlinked directories)
* @returns {string[]} returns.brokenLinks - Array of relative paths to broken symlinks
*/
function categorizeByType(rootDir) {
// IMPLEMENTATION HERE
}
module.exports = { categorizeByType };Provides recursive directory reading with symlink support.
Install with Tessl CLI
npx tessl i tessl/npm-fs-readdir-recursive