node_modules/snyk/dist/cli/293.index.js
/**
 * Walk the provided directory tree, depth first, yielding the matched filename
 * to the caller. An optional `maxDepth` argument can be provided to limit how
 * deep in the file tree the search will go.
 */
Walk the provided directory tree, depth first, yielding the matched filename
to the caller. An optional `maxDepth` argument can be provided to limit how
deep in the file tree the search will go.
Walk the provided directory tree depth first yielding the matched filename to the caller . An optional ` maxDepth ` argument can be provided to limit how deep in the file tree the search will go .
function* makeDirectoryIterator(root, options = {}) {
    if (!isDirectory(root)) {
        throw new Error(`Path "${root}" is not a directory`);
    }
    function* walk(dirpath, currentDepth) {
        const filenames = fs.readdirSync(dirpath);
        for (const filename of filenames) {
            if (!options.includeDotfiles && filename.startsWith('.')) {
                continue;
            }
            const resolved = path_1.resolve(dirpath, filename);
            if (isDirectory(resolved)) {
                if (options.maxDepth === currentDepth) {
                    continue;
                }
                yield* walk(resolved, currentDepth + 1);
            }
            else {
                yield resolved;
            }
        }
    }
    yield* walk(root, 1);
}
function * makeDirectoryIterator ( root , options = { } ) { if ( ! isDirectory ( root ) ) { throw new Error ( ` ${ root } ` ) ; } function * walk ( dirpath , currentDepth ) { const filenames = fs . readdirSync ( dirpath ) ; for ( const filename of filenames ) { if ( ! options . includeDotfiles && filename . startsWith ( '.' ) ) { continue ; } const resolved = path_1 . resolve ( dirpath , filename ) ; if ( isDirectory ( resolved ) ) { if ( options . maxDepth === currentDepth ) { continue ; } yield * walk ( resolved , currentDepth + 1 ) ; } else { yield resolved ; } } } yield * walk ( root , 1 ) ; }
Walk the provided directory tree, depth first, yielding the matched filename
 to the caller.
Walk the provided directory tree depth first yielding the matched filename to the caller .
// Internal function to allow us to track the recursion depth. // NOTE: We filter filenames that start with a period to maintain // backwards compatibility with the original implementation that used the // "glob" package. // Skip this directory if max depth has been reached.