| 9 | const TEST_INDEX = join(TEST_DIR, "index.html"); |
| 10 | |
| 11 | const crawl = (path, tree = {}) => { |
| 12 | for (const file of readdirSync(path)) { |
| 13 | const current = join(path, file); |
| 14 | if (current === TEST_INDEX) continue; |
| 15 | if (lstatSync(current).isDirectory()) { |
| 16 | if (EXCLUDE_DIR.has(file)) continue; |
| 17 | const sub = {}; |
| 18 | tree[file] = sub; |
| 19 | crawl(current, sub); |
| 20 | if (!Reflect.ownKeys(sub).length) { |
| 21 | delete tree[file]; |
| 22 | } |
| 23 | } else if (file.endsWith(".html")) { |
| 24 | const name = file === "index.html" ? "." : file.slice(0, -5); |
| 25 | tree[name] = current.replace(TEST_DIR, ""); |
| 26 | } |
| 27 | } |
| 28 | return tree; |
| 29 | }; |
| 30 | |
| 31 | const createList = (tree) => { |
| 32 | const ul = ["<ul>"]; |