feat: prevent duplicate routes when generating manifest (#1410)

This commit is contained in:
Reed von Redwitz
2023-07-11 14:39:48 +02:00
committed by GitHub
parent d4c2258eb6
commit 9177d9afc3
9 changed files with 146 additions and 21 deletions
+11
View File
@@ -39,6 +39,7 @@ async function collectDir(dir: string): Promise<string[]> {
}
const paths = [];
const fileNames = new Set<string>();
const routesFolder = walk(dir, {
includeDirs: false,
includeFiles: true,
@@ -46,6 +47,16 @@ async function collectDir(dir: string): Promise<string[]> {
});
for await (const entry of routesFolder) {
const fileNameWithoutExt = relative(dir, entry.path).split(".").slice(0, -1)
.join(".");
if (fileNames.has(fileNameWithoutExt)) {
throw new Error(
`Route conflict detected. Multiple files have the same name: ${dir}${fileNameWithoutExt}`,
);
}
fileNames.add(fileNameWithoutExt);
paths.push(relative(dir, entry.path));
}