- # Ask confirmation
- var response = prompt("Delete {target_dir.escape_to_sh}? [Y/n] ")
- var accept = response != null and
- (response.to_lower == "y" or response.to_lower == "yes" or response == "")
- if not accept then return
+ # Check validity of the package to delete
+ target_dir = target_dir.simplify_path
+ var within_dir = target_dir.has_prefix(clean_nitpm_lib_dir + "/") and
+ target_dir.length > clean_nitpm_lib_dir.length + 1
+ var valid_name = name.length > 0 and name.chars.first.is_lower
+ if not valid_name or not within_dir then
+ print_error "Package name '{name}' is invalid"
+ continue
+ end