Skip to content

Commit 00b3f7e

Browse files
committed
For output file collision errors, sources are now displayed.
1 parent cf4e7b2 commit 00b3f7e

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/functions.lua2p

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ end
880880
function _G.writeOutputFile(category, pathRel, url, data, modTime, sourcePath)
881881
local pathOutputRel = rewriteOutputPath(pathRel)
882882
if site._writtenOutputFiles[pathOutputRel] then
883-
errorf("Duplicate output file '%s'.", pathOutputRel)
883+
errorf("Output file collision for '%s':\n\tSource 1: %s\n\tSource 2: %s", pathOutputRel, site._writtenOutputFiles[pathOutputRel], sourcePath)
884884
end
885885
assert(not site._writtenOutputUrls[url])
886886

@@ -916,7 +916,7 @@ function _G.writeOutputFile(category, pathRel, url, data, modTime, sourcePath)
916916
table.insert(site._writtenOutputEntries, {path=sourcePath, pathOut=pathOutputRel, url=url})
917917
table.insert(site._writtenOutputFiles, pathOutputRel)
918918
table.insert(site._writtenOutputUrls, url)
919-
site._writtenOutputFiles[pathOutputRel] = true
919+
site._writtenOutputFiles[pathOutputRel] = sourcePath
920920
site._writtenOutputUrls[url] = true
921921

922922
assert(OUTPUT_CATEGORY_SET[category], category)
@@ -930,7 +930,7 @@ end
930930
function _G.preserveExistingOutputFile(category, pathRel, url, sourcePath)
931931
local pathOutputRel = rewriteOutputPath(pathRel)
932932
if site._writtenOutputFiles[pathOutputRel] then
933-
errorf("Duplicate output file '%s'.", pathOutputRel)
933+
errorf("Output file collision for '%s':\n\tSource 1: %s\n\tSource 2: %s", pathOutputRel, site._writtenOutputFiles[pathOutputRel], sourcePath)
934934
end
935935
assert(not site._writtenOutputUrls[url])
936936

@@ -946,7 +946,7 @@ function _G.preserveExistingOutputFile(category, pathRel, url, sourcePath)
946946
table.insert(site._writtenOutputEntries, {path=sourcePath, pathOut=pathOutputRel, url=url})
947947
table.insert(site._writtenOutputFiles, pathOutputRel)
948948
table.insert(site._writtenOutputUrls, url)
949-
site._writtenOutputFiles[pathOutputRel] = true
949+
site._writtenOutputFiles[pathOutputRel] = sourcePath
950950
site._writtenOutputUrls[url] = true
951951

952952
assert(OUTPUT_CATEGORY_SET[category], category)
@@ -2225,8 +2225,8 @@ function _G.newSite()
22252225
_pagesGenerating = {--[[ [pathRelOut1]=true, ... ]]},
22262226

22272227
_writtenOutputEntries = {--[[ { path=pathRel1, pathOut=pathOutputRel1, url=url1 }, ... ]]},
2228-
_writtenOutputFiles = {--[[ [pathOutputRel1]=true, pathOutputRel1, ... ]]},
2229-
_writtenOutputUrls = {--[[ [url1]=true, url1, ... ]]},
2228+
_writtenOutputFiles = {--[[ [pathOutputRel1]=sourcePath1, pathOutputRel1, ... ]]},
2229+
_writtenOutputUrls = {--[[ [url1]=true, url1, ... ]]},
22302230
_writtenRedirects = {--[[ [url1]=targetUrl1, ... ]]},
22312231
_unwrittenRedirects = {--[[ [url1]=targetUrl1, ... ]]}, -- We use this for redirection of special URLs in .htaccess (e.g. URLs with queries).
22322232
_outputFileCount = 0,

testsite/content/alert.htm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
function showAlert() {
3+
alert("Hello, I'm an alert!");
4+
}
5+
</script>
6+
7+
<button type="button" onclick="showAlert();">Show alert</button>
File renamed without changes.

0 commit comments

Comments
 (0)