diff --git a/source/dub/dub.d b/source/dub/dub.d index 3e4802b..2e2aec1 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -313,8 +313,11 @@ recipe_content = file_content[0 .. idx].strip(); } else throw new Exception("The source file must start with a recipe comment."); + auto nidx = recipe_content.indexOf('\n'); + auto idx = recipe_content.indexOf(':'); - enforce(idx > 0, "Missing recipe file name (e.g. \"dub.sdl:\") in recipe comment"); + enforce(idx > 0 && (nidx < 0 || nidx > idx), + "The first line of the recipe comment must list the recipe file name followed by a colon (e.g. \"/+ dub.sdl:\")."); auto recipe_filename = recipe_content[0 .. idx]; recipe_content = recipe_content[idx+1 .. $]; diff --git a/test/issue103-single-file-package.sh b/test/issue103-single-file-package.sh index 64c5848..2b26447 100755 --- a/test/issue103-single-file-package.sh +++ b/test/issue103-single-file-package.sh @@ -18,3 +18,8 @@ echo "Shebang invocation produced binary in current directory" exit 1 fi + +if ${DUB} "issue103-single-file-package-error.d" 2> /dev/null; then + echo "Invalid package comment syntax did not trigger an error." + exit 1 +fi