mirror of
https://github.com/sagiegurari/cargo-make
synced 2026-06-08 17:20:03 +00:00
@@ -1,5 +1,9 @@
|
||||
## CHANGELOG
|
||||
|
||||
### v0.37.18
|
||||
|
||||
* Enhancement: config to disable all installation steps #1147
|
||||
|
||||
### v0.37.17 (2024-09-28)
|
||||
|
||||
* Fix: support encrypted drives (shorten script file names) #1150
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
[config]
|
||||
skip_core_tasks = true
|
||||
disable_install = true
|
||||
|
||||
[tasks.alt-command-example1]
|
||||
install_crate = { install_command = "custom-install" }
|
||||
command = "cargo"
|
||||
args = ["somecrate"]
|
||||
|
||||
[tasks.alt-command-example2]
|
||||
install_crate = { crate_name = "somecrate", install_command = "custom-install" }
|
||||
|
||||
@@ -65,6 +65,12 @@ pub(crate) fn install(
|
||||
flow_info: &FlowInfo,
|
||||
flow_state: Rc<RefCell<FlowState>>,
|
||||
) -> Result<(), CargoMakeError> {
|
||||
if let Some(disable_install) = flow_info.config.config.disable_install {
|
||||
if disable_install {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let validate = !task_config.should_ignore_errors();
|
||||
|
||||
let toolchain = task_config.toolchain.clone();
|
||||
|
||||
@@ -101,6 +101,20 @@ fn install_empty_args() {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn install_disabled() {
|
||||
let mut task = Task::new();
|
||||
task.install_crate = Some(InstallCrate::Value("test".to_string()));
|
||||
task.command = Some("cargo".to_string());
|
||||
task.args = Some(vec![]);
|
||||
|
||||
let mut flow_info = test::create_empty_flow_info();
|
||||
flow_info.config.config.disable_install = Some(true);
|
||||
|
||||
// this should throw but since we disabled installation, we just return
|
||||
install(&task, &flow_info, Rc::new(RefCell::new(FlowState::new()))).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn install_enabled_crate_already_installed() {
|
||||
let mut task = Task::new();
|
||||
|
||||
@@ -2172,6 +2172,8 @@ pub struct ConfigSection {
|
||||
pub time_summary: Option<bool>,
|
||||
/// Automatically load cargo aliases as cargo-make tasks
|
||||
pub load_cargo_aliases: Option<bool>,
|
||||
/// If true (default false) disable all automatic/defined installation instructions
|
||||
pub disable_install: Option<bool>,
|
||||
/// The project information member (used by workspaces)
|
||||
pub main_project_member: Option<String>,
|
||||
/// Invoked while loading the descriptor file but before loading any extended descriptor
|
||||
@@ -2294,6 +2296,10 @@ impl ConfigSection {
|
||||
self.load_cargo_aliases = extended.load_cargo_aliases.clone();
|
||||
}
|
||||
|
||||
if extended.disable_install.is_some() {
|
||||
self.disable_install = extended.disable_install.clone();
|
||||
}
|
||||
|
||||
if extended.main_project_member.is_some() {
|
||||
self.main_project_member = extended.main_project_member.clone();
|
||||
}
|
||||
|
||||
@@ -3899,6 +3899,7 @@ fn config_section_new() {
|
||||
assert!(config.reduce_output.is_none());
|
||||
assert!(config.time_summary.is_none());
|
||||
assert!(config.load_cargo_aliases.is_none());
|
||||
assert!(config.disable_install.is_none());
|
||||
assert!(config.main_project_member.is_none());
|
||||
assert!(config.load_script.is_none());
|
||||
assert!(config.linux_load_script.is_none());
|
||||
@@ -3929,6 +3930,7 @@ fn config_section_extend_all_values() {
|
||||
base.reduce_output = Some(true);
|
||||
base.time_summary = Some(true);
|
||||
base.load_cargo_aliases = Some(true);
|
||||
base.disable_install = Some(true);
|
||||
base.load_script = Some(ScriptValue::Text(vec!["base_info".to_string()]));
|
||||
base.linux_load_script = Some(ScriptValue::Text(vec![
|
||||
"linux".to_string(),
|
||||
@@ -3962,6 +3964,7 @@ fn config_section_extend_all_values() {
|
||||
extended.reduce_output = Some(false);
|
||||
extended.time_summary = Some(false);
|
||||
extended.load_cargo_aliases = Some(false);
|
||||
extended.disable_install = Some(false);
|
||||
extended.load_script = Some(ScriptValue::Text(vec![
|
||||
"extended_info".to_string(),
|
||||
"arg2".to_string(),
|
||||
@@ -3995,6 +3998,7 @@ fn config_section_extend_all_values() {
|
||||
assert!(!base.reduce_output.unwrap());
|
||||
assert!(!base.time_summary.unwrap());
|
||||
assert!(!base.load_cargo_aliases.unwrap());
|
||||
assert!(!base.disable_install.unwrap());
|
||||
assert_eq!(get_script_as_vec(base.load_script).len(), 2);
|
||||
assert_eq!(get_script_as_vec(base.linux_load_script).len(), 1);
|
||||
assert_eq!(get_script_as_vec(base.windows_load_script).len(), 1);
|
||||
@@ -4024,6 +4028,7 @@ fn config_section_extend_no_values() {
|
||||
base.reduce_output = Some(true);
|
||||
base.time_summary = Some(true);
|
||||
base.load_cargo_aliases = Some(true);
|
||||
base.disable_install = Some(true);
|
||||
base.load_script = Some(ScriptValue::Text(vec![
|
||||
"base_info".to_string(),
|
||||
"arg2".to_string(),
|
||||
@@ -4066,6 +4071,7 @@ fn config_section_extend_no_values() {
|
||||
assert!(base.reduce_output.unwrap());
|
||||
assert!(base.time_summary.unwrap());
|
||||
assert!(base.load_cargo_aliases.unwrap());
|
||||
assert!(base.disable_install.unwrap());
|
||||
assert_eq!(get_script_as_vec(base.load_script).len(), 2);
|
||||
assert_eq!(get_script_as_vec(base.linux_load_script).len(), 2);
|
||||
assert_eq!(get_script_as_vec(base.windows_load_script).len(), 2);
|
||||
@@ -4095,6 +4101,7 @@ fn config_section_extend_some_values() {
|
||||
base.reduce_output = Some(true);
|
||||
base.time_summary = Some(true);
|
||||
base.load_cargo_aliases = Some(true);
|
||||
base.disable_install = Some(true);
|
||||
base.load_script = Some(ScriptValue::Text(vec![
|
||||
"base_info".to_string(),
|
||||
"arg2".to_string(),
|
||||
@@ -4140,6 +4147,7 @@ fn config_section_extend_some_values() {
|
||||
assert!(base.reduce_output.unwrap());
|
||||
assert!(base.time_summary.unwrap());
|
||||
assert!(base.load_cargo_aliases.unwrap());
|
||||
assert!(base.disable_install.unwrap());
|
||||
assert_eq!(get_script_as_vec(base.load_script).len(), 2);
|
||||
assert_eq!(get_script_as_vec(base.linux_load_script).len(), 2);
|
||||
assert_eq!(get_script_as_vec(base.windows_load_script).len(), 2);
|
||||
|
||||
Reference in New Issue
Block a user