MCPcopy Create free account
hub / github.com/MaplebirchLeaf/SCML-DOL-maplebirchFramework / createFileTree

Function createFileTree

scripts/modpack.ts:67–79  ·  view source on GitHub ↗
(fileList: string[])

Source from the content-addressed store, hash-verified

65}
66
67interface FileTree {
68 [key: string]: FileTree | true;
69}
70
71function createFileTree(fileList: string[]): FileTree {
72 const fileTree: FileTree = Object.create(null);
73 for (const filePath of fileList) {
74 const parts = filePath.split(/[\\/]/).filter(Boolean);
75 let current = fileTree;
76 for (const part of parts) {
77 const next = current[part] ?? (current[part] = Object.create(null) as FileTree);
78 if (next === true) throw new Error(`Invalid file tree path: ${filePath}`);
79 current = next;
80 }
81 current._f_ = true;
82 }

Callers 1

createPartsFunction · 0.85

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected