about summary refs log tree commit diff
path: root/clippy_dev/src/setup/mod.rs
blob: f691ae4fa45da22e67d8700894b2365db3d4fad2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
pub mod git_hook;
pub mod intellij;
pub mod vscode;

use std::path::Path;

const CLIPPY_DEV_DIR: &str = "clippy_dev";

/// This function verifies that the tool is being executed in the clippy directory.
/// This is useful to ensure that setups only modify Clippy's resources. The verification
/// is done by checking that `clippy_dev` is a sub directory of the current directory.
///
/// It will print an error message and return `false` if the directory could not be
/// verified.
fn verify_inside_clippy_dir() -> bool {
    let path = Path::new(CLIPPY_DEV_DIR);
    if path.exists() && path.is_dir() {
        true
    } else {
        eprintln!("error: unable to verify that the working directory is clippy's directory");
        false
    }
}