feat: add cleanup option for auto-installed dependencies in build command
- Introduced a new `cleanup_deps` flag in the build command to remove dependencies that were automatically installed during the build process. - Implemented an `InterruptWatcher` to handle Ctrl-C interruptions gracefully during the build process. - Enhanced the `AutoInstalledDependencyTracker` to track and manage auto-installed dependencies, allowing for cleanup after the build. - Updated the CLI to parse the new `cleanup_deps` flag and integrated it into the build workflow. - Added tests to ensure the correct parsing of the `cleanup_deps` flag and the functionality of the dependency tracking and cleanup process. - Improved logging for package removal operations to include a verbose mode controlled by the `DEPOT_VERBOSE_REMOVE` environment variable.
This commit is contained in:
+13
@@ -97,6 +97,10 @@ pub enum Commands {
|
||||
/// Automatically install missing dependencies before building
|
||||
#[arg(long)]
|
||||
install_deps: bool,
|
||||
|
||||
/// Remove dependencies auto-installed for this build after the command finishes
|
||||
#[arg(long)]
|
||||
cleanup_deps: bool,
|
||||
},
|
||||
/// Update installed packages from configured repositories
|
||||
Update {
|
||||
@@ -360,4 +364,13 @@ mod tests {
|
||||
_ => panic!("expected build command"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_cleanup_deps_flag_is_parsed() {
|
||||
let cli = Cli::try_parse_from(["depot", "build", "--cleanup-deps", "pkg.toml"]).unwrap();
|
||||
match cli.command {
|
||||
Commands::Build { cleanup_deps, .. } => assert!(cleanup_deps),
|
||||
_ => panic!("expected build command"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user