function listFiles(rootDir, subDir = '') {
        const dir = path.posix.join(rootDir, subDir);
        if (!isDirectory(dir)) {
            return [];
        }
        return fs.readdirSync(dir)
            .reduce((files, file) => {
            const fullPath = path.posix.join(dir, file);
            const relPath = path.posix.join(subDir, file);
            const isSymbolicLink = fs.lstatSync(fullPath).isSymbolicLink();
            let stat;
            try {
                stat = fs.statSync(fullPath);
            }
            catch (e) {
                if (isSymbolicLink) {
                    // Filter out broken symbolic links. These cause fs.statSync(fullPath)
                    // to fail with `ENOENT: no such file or directory ...`
                    return files;
                }
                throw e;
            }
            const isDirectory = stat.isDirectory();
            if (isDirectory && isSymbolicLink) {
                // Filter out symbolic links to directories. An issue in yarn versions
                // older than 1.12.1 creates symbolic links to folders in the .bin folder
                // which leads to Bazel targets that cross package boundaries.
                // See https://github.com/bazelbuild/rules_nodejs/issues/428 and
                // https://github.com/bazelbuild/rules_nodejs/issues/438.
                // This is tested in /e2e/fine_grained_symlinks.
                return files;
            }
            return isDirectory ? files.concat(listFiles(rootDir, relPath)) : files.concat(relPath);
        }, [])
            // Files with spaces (\x20) or unicode characters (<\x20 && >\x7E) are not allowed in
            // Bazel runfiles. See https://github.com/bazelbuild/bazel/issues/4327
            .filter(f => !/[^\x21-\x7E]/.test(f))
            // We return a sorted array so that the order of files
            // is the same regardless of platform
            .sort();
    }
/**
     * Returns an array of all the files under a directory as relative
     * paths to the directory.
     */
Returns an array of all the files under a directory as relative
paths to the directory.
Returns an array of all the files under a directory as relative paths to the directory .
function listFiles(rootDir, subDir = '') {
        const dir = path.posix.join(rootDir, subDir);
        if (!isDirectory(dir)) {
            return [];
        }
        return fs.readdirSync(dir)
            .reduce((files, file) => {
            const fullPath = path.posix.join(dir, file);
            const relPath = path.posix.join(subDir, file);
            const isSymbolicLink = fs.lstatSync(fullPath).isSymbolicLink();
            let stat;
            try {
                stat = fs.statSync(fullPath);
            }
            catch (e) {
                if (isSymbolicLink) {
                    return files;
                }
                throw e;
            }
            const isDirectory = stat.isDirectory();
            if (isDirectory && isSymbolicLink) {
                return files;
            }
            return isDirectory ? files.concat(listFiles(rootDir, relPath)) : files.concat(relPath);
        }, [])
            .filter(f => !/[^\x21-\x7E]/.test(f))
            .sort();
    }
function listFiles ( rootDir , subDir = '' ) { const dir = path . posix . join ( rootDir , subDir ) ; if ( ! isDirectory ( dir ) ) { return [ ] ; } return fs . readdirSync ( dir ) . reduce ( ( files , file ) => { const fullPath = path . posix . join ( dir , file ) ; const relPath = path . posix . join ( subDir , file ) ; const isSymbolicLink = fs . lstatSync ( fullPath ) . isSymbolicLink ( ) ; let stat ; try { stat = fs . statSync ( fullPath ) ; } catch ( e ) { if ( isSymbolicLink ) { return files ; } throw e ; } const isDirectory = stat . isDirectory ( ) ; if ( isDirectory && isSymbolicLink ) { return files ; } return isDirectory ? files . concat ( listFiles ( rootDir , relPath ) ) : files . concat ( relPath ) ; } , [ ] ) . filter ( f => ! / [^\x21-\x7E] / . test ( f ) ) . sort ( ) ; }
Returns an array of all the files under a directory as relative
 paths to the directory.
Returns an array of all the files under a directory as relative paths to the directory .
// Filter out broken symbolic links. These cause fs.statSync(fullPath) // to fail with `ENOENT: no such file or directory ...` // Filter out symbolic links to directories. An issue in yarn versions // older than 1.12.1 creates symbolic links to folders in the .bin folder // which leads to Bazel targets that cross package boundaries. // See https://github.com/bazelbuild/rules_nodejs/issues/428 and // https://github.com/bazelbuild/rules_nodejs/issues/438. // This is tested in /e2e/fine_grained_symlinks. // Files with spaces (\x20) or unicode characters (<\x20 && >\x7E) are not allowed in // Bazel runfiles. See https://github.com/bazelbuild/bazel/issues/4327 // We return a sorted array so that the order of files // is the same regardless of platform