diff --git a/readme.markdown b/readme.markdown index bbceffd8..2288cc06 100644 --- a/readme.markdown +++ b/readme.markdown @@ -871,9 +871,11 @@ file is created instead. The binary can be named differently than the source file with the ``namedBin`` table: +The keys in ``namedBin`` are Nim source filenames (without extension), and the values are executable names. + ```nim -namedBin["main"] = "mymain" -namedBin = {"main": "mymain", "main2": "other-main"}.toTable() +namedBin["main"] = "package-name" +namedBin = {"main": "package-name", "sourcename2": "other-main"}.toTable() ``` Note that `namedBin` entries override duplicates in `bin`. diff --git a/src/nimblepkg/options.nim b/src/nimblepkg/options.nim index 7e2193c1..ff62de07 100644 --- a/src/nimblepkg/options.nim +++ b/src/nimblepkg/options.nim @@ -740,9 +740,9 @@ proc getCompilationBinary*(options: Options, pkgInfo: PackageInfo): Option[strin if optRunFile.get("").len > 0: optRunFile.get() elif pkgInfo.bin.len == 1: - toSeq(pkgInfo.bin.values)[0] + toSeq(pkgInfo.bin.keys)[0] else: - "" + return none(string) if runFile.len > 0: return some(runFile.changeFileExt(ExeExt)) diff --git a/tests/issue984/issue984.nimble b/tests/issue984/issue984.nimble new file mode 100644 index 00000000..374e137f --- /dev/null +++ b/tests/issue984/issue984.nimble @@ -0,0 +1,10 @@ +# Package + +version = "0.1.0" +author = "Locria Cyber" +srcDir = "src" + +namedBin["main"] = "issue984" + +# Dependencies +requires "nim >= 1.5.1" diff --git a/tests/issue984/src/main.nim b/tests/issue984/src/main.nim new file mode 100644 index 00000000..d37be9ba --- /dev/null +++ b/tests/issue984/src/main.nim @@ -0,0 +1 @@ +echo "Hello" \ No newline at end of file diff --git a/tests/tissues.nim b/tests/tissues.nim index 274b5cc9..693e8a8b 100644 --- a/tests/tissues.nim +++ b/tests/tissues.nim @@ -10,6 +10,12 @@ from nimblepkg/version import newVersion from nimblepkg/displaymessages import cannotUninstallPkgMsg suite "issues": + test "issue 984": + cd "issue984": + let (output, exitCode) = execNimbleYes("run") + check exitCode == QuitSuccess + check output.contains("Hello") + test "issue 801": cd "issue801": let (output, exitCode) = execNimbleYes("test")