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)
|
removeFile(options.getBinDir() / binary.str)
|
||||||
|
|
||||||
# Search for an older version of the package we are removing.
|
# Search for an older version of the package we are removing.
|
||||||
|
# So that we can reinstate its symlink.
|
||||||
let (pkgName, _) = getNameVersion(dir)
|
let (pkgName, _) = getNameVersion(dir)
|
||||||
let pkgList = getInstalledPkgsMin(options.getPkgsDir(), options)
|
let pkgList = getInstalledPkgsMin(options.getPkgsDir(), options)
|
||||||
var pkgInfo: PackageInfo
|
var pkgInfo: PackageInfo
|
||||||
|
|
@ -818,7 +819,7 @@ proc uninstall(options: Options) =
|
||||||
for pkgTup in options.action.packages:
|
for pkgTup in options.action.packages:
|
||||||
display("Looking", "for $1 ($2)" % [pkgTup.name, $pkgTup.ver],
|
display("Looking", "for $1 ($2)" % [pkgTup.name, $pkgTup.ver],
|
||||||
priority = HighPriority)
|
priority = HighPriority)
|
||||||
let installedPkgs = getInstalledPkgs(options.getPkgsDir(), options)
|
let installedPkgs = getInstalledPkgsMin(options.getPkgsDir(), options)
|
||||||
var pkgList = findAllPkgs(installedPkgs, pkgTup)
|
var pkgList = findAllPkgs(installedPkgs, pkgTup)
|
||||||
if pkgList.len == 0:
|
if pkgList.len == 0:
|
||||||
raise newException(NimbleError, "Package not found")
|
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
|
# `nimble develop` if they change their `srcDir` but I think it's a worthy
|
||||||
# compromise.
|
# compromise.
|
||||||
let contents = pkgInfo.myPath & "\n" & pkgInfo.getRealDir()
|
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.
|
# 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
|
# Save the nimble data (which might now contain reverse deps added in
|
||||||
# processDeps).
|
# processDeps).
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ proc saveNimbleMeta*(pkgDestDir, url, vcsRevision: string,
|
||||||
nimblemeta["isLink"] = %isLink
|
nimblemeta["isLink"] = %isLink
|
||||||
writeFile(pkgDestDir / "nimblemeta.json", $nimblemeta)
|
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.
|
## Overload of saveNimbleMeta for linked (.nimble-link) packages.
|
||||||
##
|
##
|
||||||
## pkgDestDir - The directory where the package has been installed.
|
## 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.
|
## pkgDir - The directory where the original package files are.
|
||||||
## For example: ~/projects/jester/
|
## For example: ~/projects/jester/
|
||||||
saveNimbleMeta(pkgDestDir, "file://" & pkgDir, vcsRevision,
|
saveNimbleMeta(pkgDestDir, "file://" & pkgDir, vcsRevision,
|
||||||
initSet[string](), initSet[string](), true)
|
toSet[string]([nimbleLinkPath]), initSet[string](), true)
|
||||||
|
|
@ -508,3 +508,13 @@ suite "develop feature":
|
||||||
checkpoint output
|
checkpoint output
|
||||||
check(output.processOutput.inLines("hello"))
|
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