xtask: Add command for checking packages conform to certain standards (#15236)
This PR adds a new `xtask` command for checking that packages conform to certain standards. Still a work-in-progress, but right now it checks: - If `[lints] workspace = true` is set - If packages are using non-workspace dependencies Release Notes: - N/A
This commit is contained in:
@@ -1,17 +1,9 @@
|
||||
use std::fs;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use cargo_toml::{Manifest, Workspace};
|
||||
use toml;
|
||||
use anyhow::{Context, Result};
|
||||
use cargo_metadata::{Metadata, MetadataCommand};
|
||||
|
||||
/// Returns the Cargo workspace.
|
||||
pub fn load_workspace() -> Result<Workspace> {
|
||||
let workspace_cargo_toml = fs::read_to_string("Cargo.toml")?;
|
||||
let workspace_cargo_toml: Manifest = toml::from_str(&workspace_cargo_toml)?;
|
||||
|
||||
let workspace = workspace_cargo_toml
|
||||
.workspace
|
||||
.ok_or_else(|| anyhow!("top-level Cargo.toml is not a Cargo workspace"))?;
|
||||
|
||||
Ok(workspace)
|
||||
pub fn load_workspace() -> Result<Metadata> {
|
||||
MetadataCommand::new()
|
||||
.exec()
|
||||
.context("failed to load cargo metadata")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user