From cf17779d4e4e56f057188b877516112c0aa0a856 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sat, 14 Dec 2013 23:36:22 +0000 Subject: [PATCH] Versions in .babel files are now verified. --- packageinfo.nim | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packageinfo.nim b/packageinfo.nim index 88c1d71..bb7fb3a 100644 --- a/packageinfo.nim +++ b/packageinfo.nim @@ -54,17 +54,27 @@ proc initPackageInfo(): TPackageInfo = proc validatePackageInfo(pkgInfo: TPackageInfo, path: string) = if pkgInfo.name == "": - quit("Incorrect .babel file: " & path & " does not contain a name field.") + raise newException(EBabel, "Incorrect .babel file: " & path & + " does not contain a name field.") if pkgInfo.version == "": - quit("Incorrect .babel file: " & path & " does not contain a version field.") + raise newException(EBabel, "Incorrect .babel file: " & path & + " does not contain a version field.") if pkgInfo.author == "": - quit("Incorrect .babel file: " & path & " does not contain an author field.") + raise newException(EBabel, "Incorrect .babel file: " & path & + " does not contain an author field.") if pkgInfo.description == "": - quit("Incorrect .babel file: " & path & " does not contain a description field.") + raise newException(EBabel, "Incorrect .babel file: " & path & + " does not contain a description field.") if pkgInfo.license == "": - quit("Incorrect .babel file: " & path & " does not contain a license field.") + raise newException(EBabel, "Incorrect .babel file: " & path & + " does not contain a license field.") if pkgInfo.backend notin ["c", "cc", "objc", "cpp", "js"]: raise newException(EBabel, "'" & pkgInfo.backend & "' is an invalid backend.") + for c in pkgInfo.version: + if c notin ({'.'} + digits): + raise newException(EBabel, + "Version may only consist of numbers and the '.' character " & + "but found '" & c & "'.") proc parseRequires(req: string): tuple[name: string, ver: PVersionRange] = try: