mirror of
https://github.com/sagiegurari/cargo-make
synced 2026-06-08 17:20:03 +00:00
specify min cargo-make version in build #243
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
|
||||
[config]
|
||||
min_version = "0.20.1"
|
||||
@@ -92,6 +92,20 @@ fn run(cli_args: CliArgs, global_config: &GlobalConfig) {
|
||||
let experimental = cli_args.experimental;
|
||||
let config = descriptor::load(&build_file, force_makefile, env, experimental);
|
||||
|
||||
match config.config.min_version {
|
||||
Some(ref min_version) => {
|
||||
if version::is_newer_found(&min_version) {
|
||||
error!(
|
||||
"{} version: {} does not meet minimum required version: {}",
|
||||
&cli_args.command, &VERSION, &min_version
|
||||
);
|
||||
}
|
||||
|
||||
()
|
||||
}
|
||||
None => (),
|
||||
};
|
||||
|
||||
match config.config.additional_profiles {
|
||||
Some(ref profiles) => profile::set_additional(profiles),
|
||||
None => profile::set_additional(&vec![]),
|
||||
|
||||
@@ -1353,6 +1353,8 @@ pub struct ConfigSection {
|
||||
pub on_error_task: Option<String>,
|
||||
/// Additional profile names to load
|
||||
pub additional_profiles: Option<Vec<String>>,
|
||||
/// Minimum cargo-make/makers version
|
||||
pub min_version: Option<String>,
|
||||
/// Invoked while loading the descriptor file but before loading any extended descriptor
|
||||
pub load_script: Option<Vec<String>>,
|
||||
/// acts like load_script if runtime OS is Linux (takes precedence over load_script)
|
||||
@@ -1373,6 +1375,7 @@ impl ConfigSection {
|
||||
end_task: None,
|
||||
on_error_task: None,
|
||||
additional_profiles: None,
|
||||
min_version: None,
|
||||
load_script: None,
|
||||
linux_load_script: None,
|
||||
windows_load_script: None,
|
||||
@@ -1439,6 +1442,10 @@ impl ConfigSection {
|
||||
self.additional_profiles = extended.additional_profiles.clone();
|
||||
}
|
||||
|
||||
if extended.min_version.is_some() {
|
||||
self.min_version = extended.min_version.clone();
|
||||
}
|
||||
|
||||
if extended.load_script.is_some() {
|
||||
self.load_script = extended.load_script.clone();
|
||||
}
|
||||
|
||||
@@ -1971,6 +1971,7 @@ fn config_section_new() {
|
||||
assert!(config.end_task.is_none());
|
||||
assert!(config.on_error_task.is_none());
|
||||
assert!(config.additional_profiles.is_none());
|
||||
assert!(config.min_version.is_none());
|
||||
assert!(config.load_script.is_none());
|
||||
assert!(config.linux_load_script.is_none());
|
||||
assert!(config.windows_load_script.is_none());
|
||||
|
||||
+3
-3
@@ -93,10 +93,10 @@ pub(crate) fn is_newer(old_string: &str, new_string: &str, default_result: bool)
|
||||
}
|
||||
}
|
||||
|
||||
fn is_newer_found(latest_string: &str) -> bool {
|
||||
debug!("Checking Version: {}", &latest_string);
|
||||
pub(crate) fn is_newer_found(version_string: &str) -> bool {
|
||||
debug!("Checking Version: {}", &version_string);
|
||||
|
||||
is_newer(&VERSION, &latest_string, false)
|
||||
is_newer(&VERSION, &version_string, false)
|
||||
}
|
||||
|
||||
fn print_notification(latest_string: &str) {
|
||||
|
||||
Reference in New Issue
Block a user