This commit is contained in:
Dominik Picheta 2015-12-24 10:26:07 +00:00
commit 96ddb12da8
4 changed files with 44 additions and 1 deletions

View file

@ -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.