File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -963,6 +963,7 @@ proc init(options: Options) =
963963 raise nimbleError (" Please install git or mercurial first" )
964964
965965 # Determine the package name.
966+ let hasProjectName = options.action.projName != " "
966967 let pkgName =
967968 if options.action.projName != " " :
968969 options.action.projName
@@ -974,7 +975,7 @@ proc init(options: Options) =
974975
975976 # Determine the package root.
976977 let pkgRoot =
977- if pkgName == os. getCurrentDir ().splitPath.tail :
978+ if not hasProjectName :
978979 os.getCurrentDir ()
979980 else :
980981 os.getCurrentDir () / pkgName
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import testscommon
55
66# suits imports
77
8+ import tinitcommand
89import tcheckcommand
910import tcleancommand
1011import tdevelopfeature
Original file line number Diff line number Diff line change 1+ {.used .}
2+
3+ import unittest, os
4+ import testscommon
5+
6+ from nimblepkg/ common import cd
7+
8+ suite " init" :
9+ # # https://github.com/nim-lang/nimble/pull/983
10+ test " init within directory that is invalid package name will not create new directory" :
11+ let tempdir = getTempDir () / " a-b"
12+ createDir (tempdir)
13+ cd (tempdir):
14+ let args = [" init" ]
15+ let (output, exitCode) = execNimbleYes (args)
16+ discard output
17+ check exitCode == QuitSuccess
18+ check not dirExists (" a_b" )
19+ check fileExists (" a_b.nimble" )
You can’t perform that action at this time.
0 commit comments