MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getAllPathsWithDirectories

Function getAllPathsWithDirectories

common/src/project-file-tree.ts:251–265  ·  view source on GitHub ↗
(
  nodes: FileTreeNode[],
  basePath: string = '',
)

Source from the content-addressed store, hash-verified

249}
250
251export function getAllPathsWithDirectories(
252 nodes: FileTreeNode[],
253 basePath: string = '',
254): PathInfo[] {
255 return nodes.flatMap((node) => {
256 const nodePath = basePath ? path.join(basePath, node.name) : node.name
257 if (node.type === 'file') {
258 return [{ path: nodePath, isDirectory: false }]
259 }
260 // Include the directory itself, plus recurse into children
261 const dirEntry: PathInfo = { path: nodePath, isDirectory: true }
262 const children = getAllPathsWithDirectories(node.children || [], nodePath)
263 return [dirEntry, ...children]
264 })
265}
266
267export function flattenTree(nodes: FileTreeNode[]): FileTreeNode[] {
268 return nodes.flatMap((node) => {

Callers 1

flattenFileTreeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected