Skip to content

Commit

Permalink
Allow access to dependencies in addition to dev-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 7, 2019
1 parent f4abe76 commit 46bb9ff
Showing 2 changed files with 14 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/dependencies.rs
Original file line number Diff line number Diff line change
@@ -21,19 +21,26 @@ fn try_get(manifest_dir: &Path) -> Result<Manifest, Error> {

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<String, Dependency>, 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<String, Vec<String>>,
#[serde(default)]
pub dependencies: Map<String, Dependency>,
#[serde(default, rename = "dev-dependencies")]
pub dev_dependencies: Map<String, Dependency>,
}
8 changes: 4 additions & 4 deletions src/run.rs
Original file line number Diff line number Diff line change
@@ -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(),

0 comments on commit 46bb9ff

Please sign in to comment.