Merge branch 'fix-403' of https://github.com/yglukhov/nimble into yglukhov-fix-403
This commit is contained in:
commit
596d17804f
3 changed files with 45 additions and 10 deletions
|
|
@ -615,16 +615,28 @@ proc listPaths(options: Options) =
|
||||||
if kind != pcDir or not path.startsWith(options.getPkgsDir / name):
|
if kind != pcDir or not path.startsWith(options.getPkgsDir / name):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
let
|
var nimbleFile = path / name.addFileExt("nimble")
|
||||||
nimbleFile = path / name.addFileExt("nimble")
|
var nimbleLinkTargetPath: string
|
||||||
hasSpec = nimbleFile.existsFile
|
if not nimbleFile.existsFile:
|
||||||
|
let nimbleLinkFile = path / name.addFileExt("nimble-link")
|
||||||
|
if fileExists(nimbleLinkFile):
|
||||||
|
let lnk = readNimbleLink(nimbleLinkFile)
|
||||||
|
nimbleFile = lnk.nimbleFilePath
|
||||||
|
nimbleLinkTargetPath = lnk.packageDir
|
||||||
|
|
||||||
if hasSpec:
|
if nimbleFile.existsFile:
|
||||||
var pkgInfo = getPkgInfo(path, options)
|
var pkgInfo = getPkgInfo(path, options)
|
||||||
var v: VersionAndPath
|
var v: VersionAndPath
|
||||||
v.version = newVersion(pkgInfo.specialVersion)
|
v.version = newVersion(pkgInfo.specialVersion)
|
||||||
v.path = options.getPkgsDir / (pkgInfo.name & '-' & pkgInfo.specialVersion)
|
if nimbleLinkTargetPath.len == 0:
|
||||||
installed.add(v)
|
v.path = options.getPkgsDir / (pkgInfo.name & '-' & pkgInfo.specialVersion)
|
||||||
|
installed.add(v)
|
||||||
|
else:
|
||||||
|
# If we have a nimble-developed package, this is really the path we're
|
||||||
|
# looking for.
|
||||||
|
v.path = nimbleLinkTargetPath
|
||||||
|
installed = @[v]
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
display("Warning:", "No .nimble file found for " & path, Warning,
|
display("Warning:", "No .nimble file found for " & path, Warning,
|
||||||
MediumPriority)
|
MediumPriority)
|
||||||
|
|
@ -865,9 +877,9 @@ proc developFromDir(dir: string, options: Options) =
|
||||||
# need to be read. This will mean that users will need to re-run
|
# need to be read. This will mean that users will need to re-run
|
||||||
# `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 nimbleLinkPath = pkgDestDir / pkgInfo.name.addFileExt("nimble-link")
|
let nimbleLinkPath = pkgDestDir / pkgInfo.name.addFileExt("nimble-link")
|
||||||
writeFile(nimbleLinkPath, contents)
|
writeNimbleLink(nimbleLinkPath,
|
||||||
|
NimbleLink(nimbleFilePath: pkgInfo.myPath, packageDir: pkgInfo.getRealDir()))
|
||||||
|
|
||||||
# Save a nimblemeta.json file.
|
# Save a nimblemeta.json file.
|
||||||
saveNimbleMeta(pkgDestDir, "file://" & dir, vcsRevisionInDir(dir),
|
saveNimbleMeta(pkgDestDir, "file://" & dir, vcsRevisionInDir(dir),
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ type
|
||||||
MetaData* = object
|
MetaData* = object
|
||||||
url*: string
|
url*: string
|
||||||
|
|
||||||
|
NimbleLink* = object
|
||||||
|
nimbleFilePath*: string
|
||||||
|
packageDir*: string
|
||||||
|
|
||||||
proc initPackageInfo*(path: string): PackageInfo =
|
proc initPackageInfo*(path: string): PackageInfo =
|
||||||
result.myPath = path
|
result.myPath = path
|
||||||
result.specialVersion = ""
|
result.specialVersion = ""
|
||||||
|
|
@ -141,6 +145,15 @@ proc readMetaData*(path: string): MetaData =
|
||||||
let jsonmeta = parseJson(cont)
|
let jsonmeta = parseJson(cont)
|
||||||
result.url = jsonmeta["url"].str
|
result.url = jsonmeta["url"].str
|
||||||
|
|
||||||
|
proc readNimbleLink*(nimbleLinkPath: string): NimbleLink =
|
||||||
|
let s = readFile(nimbleLinkPath).splitLines()
|
||||||
|
result.nimbleFilePath = s[0]
|
||||||
|
result.packageDir = s[1]
|
||||||
|
|
||||||
|
proc writeNimbleLink*(nimbleLinkPath: string, contents: NimbleLink) =
|
||||||
|
let c = contents.nimbleFilePath & "\n" & contents.packageDir
|
||||||
|
writeFile(nimbleLinkPath, c)
|
||||||
|
|
||||||
proc needsRefresh*(options: Options): bool =
|
proc needsRefresh*(options: Options): bool =
|
||||||
## Determines whether a ``nimble refresh`` is needed.
|
## Determines whether a ``nimble refresh`` is needed.
|
||||||
##
|
##
|
||||||
|
|
@ -298,8 +311,7 @@ proc findNimbleFile*(dir: string; error: bool): string =
|
||||||
|
|
||||||
if result.splitFile.ext == ".nimble-link":
|
if result.splitFile.ext == ".nimble-link":
|
||||||
# Return the path of the real .nimble file.
|
# Return the path of the real .nimble file.
|
||||||
let lines = readFile(result).splitLines()
|
result = readNimbleLink(result).nimbleFilePath
|
||||||
result = lines[0]
|
|
||||||
if not fileExists(result):
|
if not fileExists(result):
|
||||||
raiseNimbleError("The .nimble-link file is pointing to a missing" &
|
raiseNimbleError("The .nimble-link file is pointing to a missing" &
|
||||||
" file: " & result)
|
" file: " & result)
|
||||||
|
|
|
||||||
|
|
@ -560,6 +560,17 @@ suite "develop feature":
|
||||||
let (_, exitCode) = execNimble("develop", "-y", url)
|
let (_, exitCode) = execNimble("develop", "-y", url)
|
||||||
check exitCode == QuitSuccess
|
check exitCode == QuitSuccess
|
||||||
|
|
||||||
|
test "nimble path points to develop":
|
||||||
|
cd "develop/srcdirtest":
|
||||||
|
var (output, exitCode) = execNimble("develop")
|
||||||
|
checkpoint output
|
||||||
|
check exitCode == QuitSuccess
|
||||||
|
|
||||||
|
(output, exitCode) = execNimble("path", "srcdirtest")
|
||||||
|
checkpoint output
|
||||||
|
check exitCode == QuitSuccess
|
||||||
|
check output.strip() == getCurrentDir() / "src"
|
||||||
|
|
||||||
suite "test command":
|
suite "test command":
|
||||||
test "Runs passing unit tests":
|
test "Runs passing unit tests":
|
||||||
cd "testCommand/testsPass":
|
cd "testCommand/testsPass":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue