Fixes #126.
This commit is contained in:
parent
5524024229
commit
96ddb12da8
4 changed files with 44 additions and 1 deletions
|
|
@ -54,7 +54,7 @@ proc validatePackageName*(name: string) =
|
|||
|
||||
if name[0] in {'0'..'9'}:
|
||||
raise newException(NimbleError,
|
||||
"Invalid package name: cannot beging with " & name[0])
|
||||
"Invalid package name: cannot begin with " & name[0])
|
||||
|
||||
var prevWasUnderscore = false
|
||||
for c in name:
|
||||
|
|
@ -90,6 +90,11 @@ proc validatePackageInfo(pkgInfo: PackageInfo, path: string) =
|
|||
if pkgInfo.name == "":
|
||||
raise newException(NimbleError, "Incorrect .nimble file: " & path &
|
||||
" does not contain a name field.")
|
||||
|
||||
if pkgInfo.name.normalize != path.splitFile.name.normalize:
|
||||
raise newException(NimbleError,
|
||||
"The .nimble file name must match name specified inside it.")
|
||||
|
||||
if pkgInfo.version == "":
|
||||
raise newException(NimbleError, "Incorrect .nimble file: " & path &
|
||||
" does not contain a version field.")
|
||||
|
|
@ -231,6 +236,8 @@ proc readPackageInfo*(nf: NimbleFile; onlyMinimalInfo=false): PackageInfo =
|
|||
## populated. The isNimScript field can also be relied on.
|
||||
result = initPackageInfo(nf)
|
||||
|
||||
validatePackageName(nf.splitFile.name)
|
||||
|
||||
var success = false
|
||||
var iniError: ref NimbleError
|
||||
# Attempt ini-format first.
|
||||
|
|
|
|||
11
tests/issue126/a/issue-126.nimble
Normal file
11
tests/issue126/a/issue-126.nimble
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Test to see if certain characters are disallowed in pkg names."
|
||||
license = "BSD"
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.12.1"
|
||||
|
||||
12
tests/issue126/b/issue126.nimble
Normal file
12
tests/issue126/b/issue126.nimble
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Package
|
||||
|
||||
packageName = "foobar"
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Test to see if certain characters are disallowed in pkg names."
|
||||
license = "BSD"
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.12.1"
|
||||
|
||||
|
|
@ -65,6 +65,19 @@ test "issue #27":
|
|||
cd "issue27":
|
||||
check execCmdEx("../" & path & " install -y").exitCode == QuitSuccess
|
||||
|
||||
test "issue #126":
|
||||
cd "issue126/a":
|
||||
let (output, exitCode) = execCmdEx("../../" & path & " install")
|
||||
let lines = output.strip.splitLines()
|
||||
check exitCode != QuitSuccess
|
||||
check "Invalid package name: cannot contain '-'" in lines[^1]
|
||||
|
||||
cd "issue126/b":
|
||||
let (output1, exitCode1) = execCmdEx("../../" & path & " install")
|
||||
let lines1 = output1.strip.splitLines()
|
||||
check exitCode1 != QuitSuccess
|
||||
check "The .nimble file name must match name specified inside it." in lines1[^1]
|
||||
|
||||
test "can list":
|
||||
check execCmdEx(path & " list").exitCode == QuitSuccess
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue