Refactor plugin/config loading, add theme-only plugin package support (#20556)

This commit is contained in:
Sebastian
2026-04-02 01:50:22 +02:00
committed by GitHub
parent 854484babf
commit f6fd43e574
24 changed files with 1246 additions and 539 deletions

View File

@@ -166,17 +166,42 @@ export namespace Filesystem {
return !relative(parent, child).startsWith("..")
}
export async function findUp(target: string, start: string, stop?: string) {
export async function findUp(
target: string,
start: string,
stop?: string,
options?: { rootFirst?: boolean },
): Promise<string[]>
export async function findUp(
target: string[],
start: string,
stop?: string,
options?: { rootFirst?: boolean },
): Promise<string[]>
export async function findUp(
target: string | string[],
start: string,
stop?: string,
options?: { rootFirst?: boolean },
) {
const dirs = [start]
let current = start
const result = []
while (true) {
const search = join(current, target)
if (await exists(search)) result.push(search)
if (stop === current) break
const parent = dirname(current)
if (parent === current) break
dirs.push(parent)
current = parent
}
const targets = Array.isArray(target) ? target : [target]
const result = []
for (const dir of options?.rootFirst ? dirs.toReversed() : dirs) {
for (const item of targets) {
const search = join(dir, item)
if (await exists(search)) result.push(search)
}
}
return result
}