diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 548e46f..c069d89 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -896,7 +896,7 @@ private bool loadCwdPackage(Dub dub, bool warn_missing_package) { - auto filePath = Package.findPackageFile(dub.rootPath); + auto filePath = dub.packageManager.findPackageFile(dub.rootPath); if (filePath.empty) { if (warn_missing_package) { diff --git a/source/dub/package_.d b/source/dub/package_.d index 0ebfea3..94d2597 100644 --- a/source/dub/package_.d +++ b/source/dub/package_.d @@ -153,6 +153,7 @@ Returns the full path to the package file, if any was found. Otherwise returns an empty path. */ + deprecated("Use `PackageManager.findPackageFile`") static NativePath findPackageFile(NativePath directory) { foreach (file; packageInfoFiles) { diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 987b457..a7ebcb1 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -381,7 +381,7 @@ StrictMode mode = StrictMode.Ignore) { if (recipe.empty) - recipe = Package.findPackageFile(path); + recipe = this.findPackageFile(path); enforce(!recipe.empty, "No package file found in %s, expected one of %s" @@ -396,6 +396,24 @@ return ret; } + /** Searches the given directory for package recipe files. + * + * Params: + * directory = The directory to search + * + * Returns: + * Returns the full path to the package file, if any was found. + * Otherwise returns an empty path. + */ + public NativePath findPackageFile(NativePath directory) + { + foreach (file; packageInfoFiles) { + auto filename = directory ~ file.filename; + if (this.existsFile(filename)) return filename; + } + return NativePath.init; + } + /** For a given SCM repository, returns the corresponding package. An SCM repository is provided as its remote URL, the repository is cloned @@ -1452,7 +1470,7 @@ } if (!pp) { - auto infoFile = Package.findPackageFile(path); + auto infoFile = manager.findPackageFile(path); if (!infoFile.empty) pp = manager.load(path, infoFile); else { logWarn("Locally registered package %s %s was not found. Please run 'dub remove-local \"%s\"'.", @@ -1533,7 +1551,7 @@ if (!pdir.isDirectory) continue; const pack_path = path ~ (pdir.name ~ "/"); - auto packageFile = Package.findPackageFile(pack_path); + auto packageFile = mgr.findPackageFile(pack_path); if (isManaged(path)) { // Old / flat directory structure, used in non-standard path @@ -1554,7 +1572,7 @@ if (!versdir.isDirectory) continue; auto vers_path = pack_path ~ versdir.name ~ (pdir.name ~ "/"); if (!mgr.existsDirectory(vers_path)) continue; - packageFile = Package.findPackageFile(vers_path); + packageFile = mgr.findPackageFile(vers_path); loadInternal(vers_path, packageFile); } } diff --git a/source/dub/test/base.d b/source/dub/test/base.d index 17fcb6b..38a964b 100644 --- a/source/dub/test/base.d +++ b/source/dub/test/base.d @@ -398,16 +398,6 @@ return ret; } - /// Reimplementation of `Package.findPackageFile` - public NativePath findPackageFile(NativePath directory) - { - foreach (file; packageInfoFiles) { - auto filename = directory ~ file.filename; - if (this.fs.existsFile(filename)) return filename; - } - return NativePath.init; - } - /** * Re-Implementation of `gitClone`. *