diff --git a/Cargo.lock b/Cargo.lock index 155e423..9383984 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -741,7 +741,6 @@ dependencies = [ "libc", "log", "semver", - "serde_json", "strip-ansi-escapes", "time-humanize", "toml", diff --git a/Cargo.toml b/Cargo.toml index 977c9d9..adf9348 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,6 @@ honggfuzz = { package = "ziggy-honggfuzz-2", version = "0.5.55", optional = true libc = { version = "0.2.154", optional = true } log = { version = "0.4.21", optional = true } semver = { version = "1.0.23", optional = true } -serde_json = { version = "1.0.116", optional = true } strip-ansi-escapes = { version = "0.2.0", optional = true } time-humanize = { version = "0.1.3", optional = true } toml = { version = "0.8.12", optional = true } @@ -42,7 +41,6 @@ cli = [ "toml", "semver", "anyhow", - "serde_json", "log", "env_logger", "strip-ansi-escapes", diff --git a/src/bin/cargo-ziggy/coverage.rs b/src/bin/cargo-ziggy/coverage.rs index 990f6fe..cf83db6 100644 --- a/src/bin/cargo-ziggy/coverage.rs +++ b/src/bin/cargo-ziggy/coverage.rs @@ -72,21 +72,8 @@ impl Cover { let source_or_workspace_root = match &self.source { Some(s) => s.display().to_string(), None => { - // TODO use cargo_metadata - let metadata_output = std::process::Command::new("cargo") - .arg("metadata") - .output() - .context("Failed to run cargo metadata")?; - - let stdout = - String::from_utf8(metadata_output.stdout).context("Failed to read stdout")?; - let metadata: serde_json::Value = - serde_json::from_str(&stdout).context("Failed to parse JSON")?; - - metadata["workspace_root"] - .as_str() - .context("Failed to get workspace root")? - .to_string() + let metadata = cargo_metadata::MetadataCommand::new().exec().unwrap(); + metadata.workspace_root.into() } }; diff --git a/src/bin/cargo-ziggy/main.rs b/src/bin/cargo-ziggy/main.rs index 3d55e4d..99b889a 100644 --- a/src/bin/cargo-ziggy/main.rs +++ b/src/bin/cargo-ziggy/main.rs @@ -330,6 +330,8 @@ pub fn find_target(target: &String) -> Result { } fn guess_target() -> Result { + // TODO Use cargo-metadata and remove toml dependency + let cargo_toml_string = fs::read_to_string("Cargo.toml") .context("⚠️ couldn't find Cargo.toml in this folder, cannot guess target")?; let cargo_toml = cargo_toml_string.parse::().context(