Skip to content

Commit

Permalink
fix #1107 get rid of pkg suffix (#1108)
Browse files Browse the repository at this point in the history
* fix #1107 get rid of pkg suffix

* fix test
  • Loading branch information
bung87 authored May 23, 2023
1 parent 308ef04 commit 7484582
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/nimblepkg/init.nim
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ proc initSubmodule*(): Submodule =
# This is just an example to get you started. A typical hybrid package
# uses this file as the main entry point of the application.
import $1pkg/submodule
import $1/submodule
when isMainModule:
echo(getWelcomeMessage())
""" % info.pkgName
)

let pkgSubDir = pkgRoot / info.pkgSrcDir / info.pkgName & "pkg"
let pkgSubDir = pkgRoot / info.pkgSrcDir / info.pkgName
createDirD(pkgSubDir)
let submodule = pkgSubDir / "submodule".addFileExt("nim")
writeExampleIfNonExistent(submodule,
Expand Down Expand Up @@ -146,7 +146,7 @@ test "can add":
import unittest
import $1pkg/submodule
import $1/submodule
test "correct welcome":
check getWelcomeMessage() == "Hello, World!"
""" % info.pkgName
Expand Down
9 changes: 1 addition & 8 deletions src/nimblepkg/packageparser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,7 @@ proc validatePackageStructure(pkgInfo: PackageInfo, options: Options) =
## https://github.com/nim-lang/nimble/issues/144
let
realDir = pkgInfo.getRealDir()
normalizedBinNames = toSeq(pkgInfo.bin.values).map(
(x) => x.changeFileExt("").toLowerAscii()
)
correctDir =
if pkgInfo.basicInfo.name.toLowerAscii() in normalizedBinNames:
pkgInfo.basicInfo.name & "pkg"
else:
pkgInfo.basicInfo.name
correctDir = pkgInfo.basicInfo.name

proc onFile(path: string) =
# Remove the root to leave only the package subdirectories.
Expand Down
2 changes: 1 addition & 1 deletion tests/tissues.nim
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ suite "issues":
check lines.hasLineStartingWith(
"Warning: Package 'y' has an incorrect structure. It should" &
" contain a single directory hierarchy for source files," &
" named 'ypkg', but file 'foobar.nim' is in a directory named" &
" named 'y', but file 'foobar.nim' is in a directory named" &
" 'yWrong' instead.")
of "z":
check lines.hasLineStartingWith(
Expand Down

0 comments on commit 7484582

Please sign in to comment.