pub fn detect_cleanable_project(path: &Path) -> Option<Project> {
	// A project can only be a directory
	if !path.is_dir() {
		return None;
	}

	// Create an empty project so we can add cleanable directories to it
	let mut project = Project::new(path.clone());

	// This flag will keep track of whether we've found a project
	let mut is_project = false;

	for filename in [".swpfile", ".cleanuprc"].iter() {
		if exists_in_path(path, filename) {
			project.load_swpfile(filename);

			// If a .swpfile file is found, it overrides the default paths so we can return early
			return Some(project);
		}
	}

	// Rust projects
	if exists_in_path(path, "Cargo.toml") {
		is_project = true;
		project.add_cleanable_dir_if_exists("target");
	}

	// Node.js projects
	if exists_in_path(path, "package.json") {
		is_project = true;
		project.add_cleanable_dir_if_exists("node_modules");
		project.add_cleanable_dir_if_exists(".cache");
		project.add_cleanable_dir_if_exists("build");
		project.add_cleanable_dir_if_exists("dist");
		project.add_cleanable_dir_if_exists("android/app/build");
		project.add_cleanable_dir_if_exists("android/build");
		project.add_cleanable_dir_if_exists("android/.gradle");
		project.add_cleanable_dir_if_exists("ios/build");
		project.add_cleanable_dir_if_exists("ios/Pods");
	}

	// Java projects
	if exists_in_path(path, "pom.xml") {
		is_project = true;
		project.add_cleanable_dir_if_exists("target");
		project.add_cleanable_dir_if_exists(".gradle");
		project.add_cleanable_dir_if_exists("build");
	}

	if is_project {
		return Some(project);
	} else {
		return None;
	}
}
/// Checks if a given directory is cleanable and identifies the
/// dependency subdirectories
///
/// # Arguments
/// `path` - The path to check
///
/// # Returns
/// The identified project, or None if the given path is not a project
Checks if a given directory is cleanable and identifies the
dependency subdirectories
Checks if a given directory is cleanable and identifies the dependency subdirectories
pub fn detect_cleanable_project(path: &Path) -> Option<Project> {
	// A project can only be a directory
	if !path.is_dir() {
		return None;
	}
	// Create an empty project so we can add cleanable directories to it
	let mut project = Project::new(path.clone());
	// This flag will keep track of whether we've found a project
	let mut is_project = false;
	for filename in [".swpfile", ".cleanuprc"].iter() {
		if exists_in_path(path, filename) {
			project.load_swpfile(filename);
			// If a .swpfile file is found, it overrides the default paths so we can return early
			return Some(project);
		}
	}
	// Rust projects
	if exists_in_path(path, "Cargo.toml") {
		is_project = true;
		project.add_cleanable_dir_if_exists("target");
	}
	// Node.js projects
	if exists_in_path(path, "package.json") {
		is_project = true;
		project.add_cleanable_dir_if_exists("node_modules");
		project.add_cleanable_dir_if_exists(".cache");
		project.add_cleanable_dir_if_exists("build");
		project.add_cleanable_dir_if_exists("dist");
		project.add_cleanable_dir_if_exists("android/app/build");
		project.add_cleanable_dir_if_exists("android/build");
		project.add_cleanable_dir_if_exists("android/.gradle");
		project.add_cleanable_dir_if_exists("ios/build");
		project.add_cleanable_dir_if_exists("ios/Pods");
	}
	// Java projects
	if exists_in_path(path, "pom.xml") {
		is_project = true;
		project.add_cleanable_dir_if_exists("target");
		project.add_cleanable_dir_if_exists(".gradle");
		project.add_cleanable_dir_if_exists("build");
	}
	if is_project {
		return Some(project);
	} else {
		return None;
	}
}
pub fn detect_cleanable_project ( path : & Path ) -> Option < Project > { // A project can only be a directory if ! path . is_dir ( ) { return None ; } // Create an empty project so we can add cleanable directories to it let mut project = Project :: new ( path . clone ( ) ) ; // This flag will keep track of whether we've found a project let mut is_project = false ; for filename in [ " " , " " ] . iter ( ) { if exists_in_path ( path , filename ) { project . load_swpfile ( filename ) ; // If a .swpfile file is found, it overrides the default paths so we can return early return Some ( project ) ; } } // Rust projects if exists_in_path ( path , " " ) { is_project = true ; project . add_cleanable_dir_if_exists ( " " ) ; } // Node.js projects if exists_in_path ( path , " " ) { is_project = true ; project . add_cleanable_dir_if_exists ( " " ) ; project . add_cleanable_dir_if_exists ( " " ) ; project . add_cleanable_dir_if_exists ( " " ) ; project . add_cleanable_dir_if_exists ( " " ) ; project . add_cleanable_dir_if_exists ( " " ) ; project . add_cleanable_dir_if_exists ( " " ) ; project . add_cleanable_dir_if_exists ( " " ) ; project . add_cleanable_dir_if_exists ( " " ) ; project . add_cleanable_dir_if_exists ( " " ) ; } // Java projects if exists_in_path ( path , " " ) { is_project = true ; project . add_cleanable_dir_if_exists ( " " ) ; project . add_cleanable_dir_if_exists ( " " ) ; project . add_cleanable_dir_if_exists ( " " ) ; } if is_project { return Some ( project ) ; } else { return None ; } }
Checks if a given directory is cleanable and identifies the
dependency subdirectories
Checks if a given directory is cleanable and identifies the dependency subdirectories
path
&Path
The identified project, or None if the given path is not a project
The identified project or None if the given path is not a project
path
&Path