diff --git a/src/nimble.nim b/src/nimble.nim index 4685eb0..666a60f 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -1040,7 +1040,7 @@ proc test(options: Options) = display("Error:", error, Error, HighPriority) proc check(options: Options) = - ## Validates a package a in the current working directory. + ## Validates a package in the current working directory. let nimbleFile = findNimbleFile(getCurrentDir(), true) var error: ValidationError var pkgInfo: PackageInfo @@ -1134,8 +1134,10 @@ when isMainModule: var error = "" var hint = "" + var opt: Options try: - parseCmdLine().doAction() + opt = parseCmdLine() + opt.doAction() except NimbleError: let currentExc = (ref NimbleError)(getCurrentException()) (error, hint) = getOutputInfo(currentExc) @@ -1143,7 +1145,9 @@ when isMainModule: discard finally: try: - removeDir(getNimbleTempDir()) + let folder = getNimbleTempDir() + if opt.shouldRemoveTmp(folder): + removeDir(folder) except OSError: let msg = "Couldn't remove Nimble's temp dir" display("Warning:", msg, Warning, MediumPriority) diff --git a/src/nimblepkg/nimscriptwrapper.nim b/src/nimblepkg/nimscriptwrapper.nim index d1f8d7a..d7b7a3b 100644 --- a/src/nimblepkg/nimscriptwrapper.nim +++ b/src/nimblepkg/nimscriptwrapper.nim @@ -36,8 +36,8 @@ proc execNimscript(nimsFile, projectDir, actionName: string, options: Options): defer: # Only if copied in this invocation, allows recursive calls of nimble - if not isScriptResultCopied: - nimsFileCopied.removeFile() + if not isScriptResultCopied and options.shouldRemoveTmp(nimsFileCopied): + nimsFileCopied.removeFile() var cmd = ("nim e --hints:off --verbosity:0 -p:" & (getTempDir() / "nimblecache").quoteShell & @@ -56,7 +56,8 @@ proc execNimscript(nimsFile, projectDir, actionName: string, options: Options): result.exitCode = execCmd(cmd) if outFile.fileExists(): result.output = outFile.readFile() - discard outFile.tryRemoveFile() + if options.shouldRemoveTmp(outFile): + discard outFile.tryRemoveFile() proc getNimsFile(scriptName: string, options: Options): string = let diff --git a/src/nimblepkg/options.nim b/src/nimblepkg/options.nim index 3482f34..80a649d 100644 --- a/src/nimblepkg/options.nim +++ b/src/nimblepkg/options.nim @@ -425,3 +425,10 @@ proc briefClone*(options: Options): Options = newOptions.forcePrompts = options.forcePrompts newOptions.pkgInfoCache = options.pkgInfoCache return newOptions + +proc shouldRemoveTmp*(options: Options, file: string): bool = + result = true + if options.verbosity <= DebugPriority: + let msg = "Not removing temporary path because of debug verbosity: " & file + display("Warning:", msg, Warning, MediumPriority) + return false \ No newline at end of file