diff --git a/source/dub/internal/utils.d b/source/dub/internal/utils.d index c9b5b34..1b1b41b 100644 --- a/source/dub/internal/utils.d +++ b/source/dub/internal/utils.d @@ -690,6 +690,10 @@ * Search for module keyword in file */ string getModuleNameFromFile(string filePath) { + if (!filePath.exists) + { + return null; + } string fileContent = filePath.readText; logDiagnostic("Get module name from path: %s", filePath); diff --git a/test/.gitignore b/test/.gitignore index e09cda6..cfe8d61 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -37,6 +37,7 @@ */*test-application */exec-simple issue1474/ext/fortytwo.d +issue2452/ext/fortytwo.d cov-ctfe/test issue1003-check-empty-ld-flags/issue1003-empty-ld-flags diff --git a/test/issue2452/dub.json b/test/issue2452/dub.json new file mode 100644 index 0000000..40f2fd0 --- /dev/null +++ b/test/issue2452/dub.json @@ -0,0 +1,9 @@ +{ + "name": "generated-sources-and-source-files-without-glob", + "description": "Example of using pre generate commands and sourceFiles without glob.", + "sourceFiles": ["ext/fortytwo.d"], + "preGenerateCommands": [ + "mkdir -p ext", + "echo 'extern(C) int fun42 () { return 42; }' > ext/fortytwo.d" + ] +} diff --git a/test/issue2452/source/app.d b/test/issue2452/source/app.d new file mode 100644 index 0000000..6c0c6fa --- /dev/null +++ b/test/issue2452/source/app.d @@ -0,0 +1,8 @@ +import std.stdio; + +import fortytwo; + +void main() +{ + writefln("ShouldBe42: %s", fun42()); +}