From ae4fc39a7ade6b158c9f88668ec58adb04a0b9b3 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sun, 9 Sep 2018 16:01:40 +0100 Subject: [PATCH] Fixes check for existing .nimble file in `nimble init.` --- src/nimble.nim | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/nimble.nim b/src/nimble.nim index 396348a..22d7955 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -698,15 +698,6 @@ proc dump(options: Options) = echo "backend: ", p.backend.escape proc init(options: Options) = - if options.forcePrompts != forcePromptYes: - display( - "Info:", - "Package initialisation requires info which could not be inferred.\n" & - "Default values are shown in square brackets, press\n" & - "enter to use them.", - priority = HighPriority - ) - # Determine the package name. let pkgName = if options.action.projName != "": @@ -726,11 +717,18 @@ proc init(options: Options) = let nimbleFile = (pkgRoot / pkgName).changeFileExt("nimble") - let nimbleFilePath = pkgRoot / nimbleFile - if existsFile(nimbleFilePath): - let errMsg = "Nimble file already exists: $#" % nimbleFilePath + if existsFile(nimbleFile): + let errMsg = "Nimble file already exists: $#" % nimbleFile raise newException(NimbleError, errMsg) + if options.forcePrompts != forcePromptYes: + display( + "Info:", + "Package initialisation requires info which could not be inferred.\n" & + "Default values are shown in square brackets, press\n" & + "enter to use them.", + priority = HighPriority + ) display("Using", "$# for new package name" % [pkgName.escape()], priority = HighPriority)