Softened package structure rules when srcDir is not specified.
Fixes #469.
This commit is contained in:
parent
fb879efb72
commit
9f4081e888
6 changed files with 29 additions and 4 deletions
|
|
@ -286,6 +286,16 @@ proc inferInstallRules(pkgInfo: var PackageInfo, options: Options) =
|
|||
if installInstructions == 0 and pkgInfo.bin.len > 0:
|
||||
pkgInfo.skipExt.add("nim")
|
||||
|
||||
# When a package doesn't specify a `srcDir` it's fair to assume that
|
||||
# the .nim files are in the root of the package. So we can explicitly select
|
||||
# them and prevent the installation of anything else. The user can always
|
||||
# override this with `installFiles`.
|
||||
if pkgInfo.srcDir == "":
|
||||
if dirExists(pkgInfo.getRealDir() / pkgInfo.name):
|
||||
pkgInfo.installDirs.add(pkgInfo.name)
|
||||
if fileExists(pkgInfo.getRealDir() / pkgInfo.name.addFileExt("nim")):
|
||||
pkgInfo.installFiles.add(pkgInfo.name.addFileExt("nim"))
|
||||
|
||||
proc readPackageInfo(nf: NimbleFile, options: Options,
|
||||
onlyMinimalInfo=false): PackageInfo =
|
||||
## Reads package info from the specified Nimble file.
|
||||
|
|
@ -360,12 +370,12 @@ proc readPackageInfo(nf: NimbleFile, options: Options,
|
|||
if version.kind == verSpecial:
|
||||
result.specialVersion = minimalInfo.version
|
||||
|
||||
if not result.isMinimal:
|
||||
options.pkgInfoCache[nf] = result
|
||||
|
||||
# Apply rules to infer which files should/shouldn't be installed. See #469.
|
||||
inferInstallRules(result, options)
|
||||
|
||||
if not result.isMinimal:
|
||||
options.pkgInfoCache[nf] = result
|
||||
|
||||
# Validate the rest of the package info last.
|
||||
if not options.disableValidation:
|
||||
validateVersion(result.version)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue