Skip to content

Commit 67e4c3b

Browse files
committed
website - improve warning when alias redirection would overwrite file
1 parent 31e496f commit 67e4c3b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/project/types/website/website-aliases.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,17 @@ export async function updateAliases(
106106

107107
// Write the redirect file
108108
if (allOutputFiles.find((outputFile) => outputFile === targetFile)) {
109-
// Do not, this is the same name as an output file!
110-
warning(
111-
`Aliases that you have created would overwrite the output file ${targetFile}. The aliases file was not created.`,
112-
);
109+
for (
110+
const offendingAlias of targetHrefs.filter(
111+
(targetHref) =>
112+
targetHref.href ===
113+
relative(dirname(targetHref.outputFile), targetFile),
114+
)
115+
) {
116+
warning(
117+
`Requested alias ${targetFile} -> ${offendingAlias.outputFile} would overwrite the target. Skipping.`,
118+
);
119+
}
113120
} else {
114121
// Write, this is a safe file
115122
writeMultipleRedirectPage(targetFile, redirects);

0 commit comments

Comments
 (0)