Skip to content

Commit

Permalink
Read Cargo.toml from target dir
Browse files Browse the repository at this point in the history
When running `crossgen` on a directory with a missing `Cargo.toml` it
would panic with an error message.

Debugging what happend, I've found it failed to find a `Cargo.toml` file, as it don't exist.
To my surprise, when I've cloned the repo and tried to reproduce using `cargo run -- ~/path/to/my-dir`, there was no panic!

This happened because the `Cargo.toml` was found on `crossgen` repo, not on my targe repo, as expected.

This commit changes the location of the manifest file to use the directory parsed from the arguments.

Signed-off-by: Bruno Tavares <[email protected]>
  • Loading branch information
bltavares committed Oct 12, 2018
1 parent 48fa6fc commit 7690cad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use cargo_toml::TomlManifest;
use crossgen::Cli;
use exitfailure::ExitFailure;
use std::fs::read;
use std::path::PathBuf;
use structopt::StructOpt;

fn main() -> Result<(), ExitFailure> {
Expand All @@ -27,7 +28,7 @@ fn main() -> Result<(), ExitFailure> {
let name = args.name()?;
let lib = args.lib();

let manifest = TomlManifest::from_slice(&read("Cargo.toml")?)?;
let manifest = TomlManifest::from_slice(&read(dir.join("Cargo.toml"))?)?;
let repo = manifest
.package
.repository
Expand Down

0 comments on commit 7690cad

Please sign in to comment.