MCPcopy Create free account
hub / github.com/esengine/esengine / buildNode

Function buildNode

packages/editor-app/src/stores/ContentBrowserStore.ts:240–271  ·  view source on GitHub ↗
(path: string, name: string)

Source from the content-addressed store, hash-verified

238 const { expandedFolders } = get();
239
240 const buildNode = async (path: string, name: string): Promise<FolderNode> => {
241 const node: FolderNode = {
242 name,
243 path,
244 children: [],
245 isExpanded: expandedFolders.has(path)
246 };
247
248 try {
249 const entries = await TauriAPI.listDirectory(path);
250 const folders = entries
251 .filter((e: DirectoryEntry) => e.is_dir && !e.name.startsWith('.'))
252 .sort((a: DirectoryEntry, b: DirectoryEntry) => a.name.localeCompare(b.name));
253
254 for (const folder of folders) {
255 if (expandedFolders.has(path)) {
256 node.children.push(await buildNode(folder.path, folder.name));
257 } else {
258 node.children.push({
259 name: folder.name,
260 path: folder.path,
261 children: [],
262 isExpanded: false
263 });
264 }
265 }
266 } catch (error) {
267 console.error('Failed to build folder tree:', error);
268 }
269
270 return node;
271 };
272
273 const tree = await buildNode(rootPath, 'All');
274 set({ folderTree: tree });

Callers 1

Calls 5

hasMethod · 0.65
listDirectoryMethod · 0.65
filterMethod · 0.65
pushMethod · 0.65
errorMethod · 0.45

Tested by

no test coverage detected