Fixes removal of linked packages (and speeds up removal).
This commit is contained in:
parent
f746f4f0f3
commit
3bdce8d332
3 changed files with 19 additions and 6 deletions
|
|
@ -336,6 +336,7 @@ proc removePkgDir(dir: string, options: Options) =
|
|||
removeFile(options.getBinDir() / binary.str)
|
||||
|
||||
# Search for an older version of the package we are removing.
|
||||
# So that we can reinstate its symlink.
|
||||
let (pkgName, _) = getNameVersion(dir)
|
||||
let pkgList = getInstalledPkgsMin(options.getPkgsDir(), options)
|
||||
var pkgInfo: PackageInfo
|
||||
|
|
@ -818,7 +819,7 @@ proc uninstall(options: Options) =
|
|||
for pkgTup in options.action.packages:
|
||||
display("Looking", "for $1 ($2)" % [pkgTup.name, $pkgTup.ver],
|
||||
priority = HighPriority)
|
||||
let installedPkgs = getInstalledPkgs(options.getPkgsDir(), options)
|
||||
let installedPkgs = getInstalledPkgsMin(options.getPkgsDir(), options)
|
||||
var pkgList = findAllPkgs(installedPkgs, pkgTup)
|
||||
if pkgList.len == 0:
|
||||
raise newException(NimbleError, "Package not found")
|
||||
|
|
@ -912,10 +913,12 @@ proc developFromDir(dir: string, options: Options) =
|
|||
# `nimble develop` if they change their `srcDir` but I think it's a worthy
|
||||
# compromise.
|
||||
let contents = pkgInfo.myPath & "\n" & pkgInfo.getRealDir()
|
||||
writeFile(pkgDestDir / pkgInfo.name.addFileExt("nimble-link"), contents)
|
||||
let nimbleLinkPath = pkgDestDir / pkgInfo.name.addFileExt("nimble-link")
|
||||
writeFile(nimbleLinkPath, contents)
|
||||
|
||||
# Save a nimblemeta.json file.
|
||||
saveNimbleMeta(pkgDestDir, "file://" & dir, vcsRevisionInDir(dir))
|
||||
saveNimbleMeta(pkgDestDir, "file://" & dir, vcsRevisionInDir(dir),
|
||||
nimbleLinkPath)
|
||||
|
||||
# Save the nimble data (which might now contain reverse deps added in
|
||||
# processDeps).
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ proc saveNimbleMeta*(pkgDestDir, url, vcsRevision: string,
|
|||
nimblemeta["isLink"] = %isLink
|
||||
writeFile(pkgDestDir / "nimblemeta.json", $nimblemeta)
|
||||
|
||||
proc saveNimbleMeta*(pkgDestDir, pkgDir, vcsRevision: string) =
|
||||
proc saveNimbleMeta*(pkgDestDir, pkgDir, vcsRevision, nimbleLinkPath: string) =
|
||||
## Overload of saveNimbleMeta for linked (.nimble-link) packages.
|
||||
##
|
||||
## pkgDestDir - The directory where the package has been installed.
|
||||
|
|
@ -103,4 +103,4 @@ proc saveNimbleMeta*(pkgDestDir, pkgDir, vcsRevision: string) =
|
|||
## pkgDir - The directory where the original package files are.
|
||||
## For example: ~/projects/jester/
|
||||
saveNimbleMeta(pkgDestDir, "file://" & pkgDir, vcsRevision,
|
||||
initSet[string](), initSet[string](), true)
|
||||
toSet[string]([nimbleLinkPath]), initSet[string](), true)
|
||||
|
|
@ -507,4 +507,14 @@ suite "develop feature":
|
|||
let (output, exitCode) = execNimble("c", "-r", "src/dependent.nim")
|
||||
checkpoint output
|
||||
check(output.processOutput.inLines("hello"))
|
||||
check exitCode == QuitSuccess
|
||||
check exitCode == QuitSuccess
|
||||
|
||||
test "can uninstall linked package":
|
||||
cd "develop/srcdirtest":
|
||||
let (_, exitCode) = execNimble("develop", "-y")
|
||||
check exitCode == QuitSuccess
|
||||
|
||||
let (output, exitCode) = execNimble("uninstall", "-y", "srcdirtest")
|
||||
checkpoint(output)
|
||||
check exitCode == QuitSuccess
|
||||
check(not output.processOutput.inLines("warning"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue