diff --git a/source/app.d b/source/app.d index 9f8878d..5efdb1a 100644 --- a/source/app.d +++ b/source/app.d @@ -122,6 +122,11 @@ Dub dub = new Dub(package_suppliers, root_path); string def_config; + // make the CWD package available so that for example sub packages can reference their + // parent package. + try dub.packageManager.getTemporaryPackage(Path(root_path), Version("~master")); + catch (Exception e) { logDiagnostic("No package found in current working directory."); } + bool loadCwdPackage(Package pack) { if (!existsFile(dub.rootPath~"package.json") && !existsFile(dub.rootPath~"source/app.d")) { @@ -234,8 +239,7 @@ pack = dub.packageManager.getFirstPackage(package_name); enforce(pack, "Failed to find a package named '"~package_name~"'."); logInfo("Building package %s in %s", pack.name, pack.path.toNativeString()); - root_path = pack.path.toNativeString(); - dub = new Dub(package_suppliers, root_path); + dub.rootPath = pack.path; } if (!loadCwdPackage(pack)) return 1; diff --git a/source/dub/dub.d b/source/dub/dub.d index 9e923b2..f072f2b 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -90,6 +90,12 @@ /** Returns the root path (usually the current working directory). */ @property Path rootPath() const { return m_rootPath; } + /// ditto + @property void rootPath(Path root_path) + { + m_rootPath = root_path; + if (!m_rootPath.absolute) m_rootPath = Path(getcwd()) ~ m_rootPath; + } /// Returns the name listed in the package.json of the current /// application.