From 46bb9ff2c5fb50ed949a52d456e7c17920e69529 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 7 May 2019 09:26:57 -0700 Subject: [PATCH] Allow access to dependencies in addition to dev-dependencies --- src/dependencies.rs | 13 ++++++++++--- src/run.rs | 8 ++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/dependencies.rs b/src/dependencies.rs index f155e22..3fc0ef1 100644 --- a/src/dependencies.rs +++ b/src/dependencies.rs @@ -21,19 +21,26 @@ fn try_get(manifest_dir: &Path) -> Result { manifest.dev_dependencies.remove("trybuild"); - for dep in manifest.dev_dependencies.values_mut() { - dep.path = dep.path.as_ref().map(|path| manifest_dir.join(path)); - } + make_relative(&mut manifest.dependencies, manifest_dir); + make_relative(&mut manifest.dev_dependencies, manifest_dir); Ok(manifest) } +fn make_relative(dependencies: &mut Map, dir: &Path) { + for dep in dependencies.values_mut() { + dep.path = dep.path.as_ref().map(|path| dir.join(path)); + } +} + #[derive(Deserialize, Default)] pub struct Manifest { #[serde(default)] pub package: Package, #[serde(default)] pub features: Map>, + #[serde(default)] + pub dependencies: Map, #[serde(default, rename = "dev-dependencies")] pub dev_dependencies: Map, } diff --git a/src/run.rs b/src/run.rs index 3a2286c..78022ee 100644 --- a/src/run.rs +++ b/src/run.rs @@ -142,6 +142,10 @@ impl Runner { workspace: Some(Workspace {}), }; + manifest.dependencies.extend(source_manifest.dependencies); + manifest + .dependencies + .extend(source_manifest.dev_dependencies); manifest.dependencies.insert( crate_name, Dependency { @@ -153,10 +157,6 @@ impl Runner { }, ); - manifest - .dependencies - .extend(source_manifest.dev_dependencies); - manifest.bins.push(Bin { name: Name(project.name.to_owned()), path: Path::new("main.rs").to_owned(),