/
githubmirror
/
deno
Обзор
Документация
Войти
/
githubmirror
/
deno
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/specs/bundle/html/same-name-sub-folder-bundle.asserts.ts
38 строк
1002 B
Nathan Whitaker
feat(bundle): support html entrypoint (#29856)
09 сен 2025, 22:18
Не верифицирован
09 сен 2025, 22:18
4e4bbf2
Код
Авторство
О чём код?
import { assertFileContains } from "./assert-helpers.ts"; assertFileContains("./dist/index.html", /src="\.\/index-[^\.]+\.js"/); assertFileContains("./dist/sub/index.html", /src="\.\/index-[^\.]+\.js"/); function walk(dir: string, fn: (entry: string) => void) { Deno.readDirSync(dir).forEach((entry) => { if (entry.isDirectory) { walk(dir + "/" + entry.name, fn); } else { fn(dir + "/" + entry.name); } }); } const jsFiles: string[] = []; walk("./dist", (entry) => { if (entry.endsWith(".js")) { jsFiles.push(entry); } }); if (jsFiles.length === 0) { throw new Error("No .js files found"); } const subJsFile = jsFiles.find((file) => file.includes("sub")); const indexJsFile = jsFiles.find((file) => file.includes("index") && !file.includes("sub") ); if (!indexJsFile || !subJsFile) { throw new Error("No index.js or sub/index.js file found"); } assertFileContains(indexJsFile, "Hello, world!"); assertFileContains(subJsFile, "Hello, world from sub!");