diff --git a/source/app.d b/source/app.d index b1e1d25..8e016fc 100644 --- a/source/app.d +++ b/source/app.d @@ -54,6 +54,7 @@ string install_version; string[] registry_urls; string[] debug_versions; + string root_path = getcwd(); getopt(args, "v|verbose", &verbose, "vverbose", &vverbose, @@ -74,7 +75,8 @@ "system", &install_system, "local", &install_local, "version", &install_version, - "registry", ®istry_urls + "registry", ®istry_urls, + "root", &root_path ); if( vverbose ) loglevel = LogLevel.debug_; @@ -111,12 +113,12 @@ logInfo(""); } - Dub dub = new Dub(registry_urls.map!(url => cast(PackageSupplier)new RegistryPackageSupplier(Url(url))).array); + Dub dub = new Dub(registry_urls.map!(url => cast(PackageSupplier)new RegistryPackageSupplier(Url(url))).array, root_path); string def_config; bool loadCwdPackage() { - if( !existsFile("package.json") && !existsFile("source/app.d") ){ + if( !existsFile(dub.rootPath~"package.json") && !existsFile(dub.rootPath~"source/app.d") ){ logInfo(""); logInfo("Neither package.json, nor source/app.d was found in the current directory."); logInfo("Please run dub from the root directory of an existing package, or create a new"); @@ -344,6 +346,7 @@ --vquiet No output --registry=URL Search the given DUB registry URL first when resolving dependencies. Can be specified multiple times. + --root=PATH Path to operate in instead of the current working dir Build/run options: --build=NAME Specifies the type of build to perform. Note that diff --git a/source/dub/dub.d b/source/dub/dub.d index 8fb1cd0..1bfe9ac 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -59,9 +59,10 @@ /// Initiales the package manager for the vibe application /// under root. - this(PackageSupplier[] additional_package_suppliers = null) + this(PackageSupplier[] additional_package_suppliers = null, string root_path = ".") { - m_cwd = Path(getcwd()); + m_cwd = Path(root_path); + if (!m_cwd.absolute) m_cwd = Path(getcwd()) ~ m_cwd; version(Windows){ m_systemDubPath = Path(environment.get("ProgramData")) ~ "dub/"; @@ -86,6 +87,10 @@ updatePackageSearchPath(); } + /** Returns the root path (usually the current working directory). + */ + @property Path rootPath() const { return m_cwd; } + /// Returns the name listed in the package.json of the current /// application. @property string projectName() const { return m_project.name; }