refactor: Define ruff_dev::ROOT_DIR

This commit is contained in:
Martin Fischer 2023-02-01 10:55:39 +01:00 committed by Charlie Marsh
parent faea478ca5
commit e66a6b6d05
3 changed files with 8 additions and 8 deletions

View file

@ -5,6 +5,8 @@ use anyhow::Result;
use ruff::settings::options::Options;
use schemars::schema_for;
use crate::ROOT_DIR;
#[derive(clap::Args)]
pub struct Args {
/// Write the generated table to stdout (rather than to `ruff.schema.json`).
@ -19,10 +21,7 @@ pub fn main(args: &Args) -> Result<()> {
if args.dry_run {
println!("{schema_string}");
} else {
let file = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.expect("Failed to find root directory")
.join("ruff.schema.json");
let file = PathBuf::from(ROOT_DIR).join("ruff.schema.json");
fs::write(file, schema_string.as_bytes())?;
}
Ok(())