Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix named bin run default #985

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions src/nimblepkg/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 10 additions & 0 deletions tests/issue984/issue984.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Package

version = "0.1.0"
author = "Locria Cyber"
srcDir = "src"

namedBin["main"] = "issue984"

# Dependencies
requires "nim >= 1.5.1"
1 change: 1 addition & 0 deletions tests/issue984/src/main.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo "Hello"
6 changes: 6 additions & 0 deletions tests/tissues.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down