code: function buildTree(directory, depth) {
    const files = fs.readdirSync(directory);
    const max_index = files.length - 1
    const color = chalk[colors[depth % colors.length]]
  
    for (let i = 0; i <= max_index; i++) {
      const file = files[i]
      depths[depth] = max_index - i
      const fullPath = path.resolve(directory, file)
      const prefix = buildPrefix(depth, i === max_index, directory)
      const stats = fs.statSync(fullPath)
      const isDirectory = stats.isDirectory()
      const size = prettybytes(stats.size)
  
      if (isDirectory) {
        directoryCount++
      } else {
        fileCount++
        totalFileSize += stats.size
      }
  
      if (!isDirectory && !shouldBeIncluded(file)) {
        return
      }
  
      const filename = useColors ? color(file) : file
      output += prefix + filename + (!isDirectory && showSize ? ` (${size})` : '') + '\n';
      if (isDirectory && (depth + 1 < maxDepth)) {
        buildTree(path.resolve(directory, file), depth + 1)
      }
      --depths[depth]
    }
  }
docs: Depth-first recursive traversal utility for
  building up the output string.