Skip to content

Commit

Permalink
Merge pull request #2 from dtolnay/dep
Browse files Browse the repository at this point in the history
Allow access to dependencies in addition to dev-dependencies
  • Loading branch information
dtolnay committed May 7, 2019
2 parents f4abe76 + 46bb9ff commit 32f36c4
Show file tree
Hide file tree
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
Expand Up @@ -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>,
}
Expand Down
8 changes: 4 additions & 4 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(),
Expand Down

0 comments on commit 32f36c4

Please sign in to comment.