Temp files are no longer removed when --debug is present.
This commit is contained in:
parent
445ecfe946
commit
36c4a39674
3 changed files with 18 additions and 6 deletions
|
|
@ -1040,7 +1040,7 @@ proc test(options: Options) =
|
||||||
display("Error:", error, Error, HighPriority)
|
display("Error:", error, Error, HighPriority)
|
||||||
|
|
||||||
proc check(options: Options) =
|
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)
|
let nimbleFile = findNimbleFile(getCurrentDir(), true)
|
||||||
var error: ValidationError
|
var error: ValidationError
|
||||||
var pkgInfo: PackageInfo
|
var pkgInfo: PackageInfo
|
||||||
|
|
@ -1134,8 +1134,10 @@ when isMainModule:
|
||||||
var error = ""
|
var error = ""
|
||||||
var hint = ""
|
var hint = ""
|
||||||
|
|
||||||
|
var opt: Options
|
||||||
try:
|
try:
|
||||||
parseCmdLine().doAction()
|
opt = parseCmdLine()
|
||||||
|
opt.doAction()
|
||||||
except NimbleError:
|
except NimbleError:
|
||||||
let currentExc = (ref NimbleError)(getCurrentException())
|
let currentExc = (ref NimbleError)(getCurrentException())
|
||||||
(error, hint) = getOutputInfo(currentExc)
|
(error, hint) = getOutputInfo(currentExc)
|
||||||
|
|
@ -1143,7 +1145,9 @@ when isMainModule:
|
||||||
discard
|
discard
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
removeDir(getNimbleTempDir())
|
let folder = getNimbleTempDir()
|
||||||
|
if opt.shouldRemoveTmp(folder):
|
||||||
|
removeDir(folder)
|
||||||
except OSError:
|
except OSError:
|
||||||
let msg = "Couldn't remove Nimble's temp dir"
|
let msg = "Couldn't remove Nimble's temp dir"
|
||||||
display("Warning:", msg, Warning, MediumPriority)
|
display("Warning:", msg, Warning, MediumPriority)
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ proc execNimscript(nimsFile, projectDir, actionName: string, options: Options):
|
||||||
|
|
||||||
defer:
|
defer:
|
||||||
# Only if copied in this invocation, allows recursive calls of nimble
|
# Only if copied in this invocation, allows recursive calls of nimble
|
||||||
if not isScriptResultCopied:
|
if not isScriptResultCopied and options.shouldRemoveTmp(nimsFileCopied):
|
||||||
nimsFileCopied.removeFile()
|
nimsFileCopied.removeFile()
|
||||||
|
|
||||||
var
|
var
|
||||||
cmd = ("nim e --hints:off --verbosity:0 -p:" & (getTempDir() / "nimblecache").quoteShell &
|
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)
|
result.exitCode = execCmd(cmd)
|
||||||
if outFile.fileExists():
|
if outFile.fileExists():
|
||||||
result.output = outFile.readFile()
|
result.output = outFile.readFile()
|
||||||
discard outFile.tryRemoveFile()
|
if options.shouldRemoveTmp(outFile):
|
||||||
|
discard outFile.tryRemoveFile()
|
||||||
|
|
||||||
proc getNimsFile(scriptName: string, options: Options): string =
|
proc getNimsFile(scriptName: string, options: Options): string =
|
||||||
let
|
let
|
||||||
|
|
|
||||||
|
|
@ -425,3 +425,10 @@ proc briefClone*(options: Options): Options =
|
||||||
newOptions.forcePrompts = options.forcePrompts
|
newOptions.forcePrompts = options.forcePrompts
|
||||||
newOptions.pkgInfoCache = options.pkgInfoCache
|
newOptions.pkgInfoCache = options.pkgInfoCache
|
||||||
return newOptions
|
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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue