[env] TRUE_ENV = "true" FALSE_ENV = "false" [tasks.test-condition] condition = { platforms = ["windows", "linux"], channels = ["beta", "nightly"] } script = ''' echo "condition was met" ''' [tasks.test-os-condition] condition = { os = ["linux"] } script = ''' echo "OS condition was met" ''' [tasks.test-rust-version-condition] condition = { rust_version = { min = "1.20.0", max = "1.30.0" } } script = ''' echo "rust version condition was met" ''' [tasks.test1] command = "echo" args = ["running test1"] [tasks.test2] command = "echo" args = ["running test2"] [tasks.test3] command = "echo" args = ["running test3"] [tasks.test-default] command = "echo" args = ["running test-default"] [tasks.test-routing] run_task = [ { name = "test1", condition = { platforms = [ "windows", "linux", ], channels = [ "beta", "stable", ] } }, { name = "test2", condition = { platforms = [ "mac", ], rust_version = { min = "1.20.0", max = "1.30.0" } } }, { name = "test3", condition_script = [ "somecommand", ] }, { name = "test-default" }, ] [tasks.test-true-condition] condition = { env_true = ["TRUE_ENV"] } script = ''' echo "condition was met" ''' [tasks.test-false-condition] condition = { env_false = ["FALSE_ENV"] } script = ''' echo "condition was met" ''' [tasks.test-file-exists-condition] condition = { files_exist = ["${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml"] } script = ''' echo "condition was met" ''' [tasks.test-file-not-exists-condition] condition = { files_not_exist = [ "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml2", ] } script = ''' echo "condition was met" ''' [tasks.test-condition-script] condition_script = """ exit 1 """ command = "echo" args = ["condition was met"] [tasks.test-condition-with-message] condition = { platforms = ["windows"], fail_message = "Condition Failed." } command = "echo" args = ["condition was met"] [tasks.test-condition-script-with-message] condition = { fail_message = "Condition Script Failed." } condition_script = """ exit 1 """ command = "echo" args = ["condition was met"] [tasks.test-condition-files-modified] condition = { files_modified = { input = [ "./examples/condition.toml", "./src/**/*", ], output = [ "./target/**/cargo-make*", ] } } command = "echo" args = ["condition was met, sources updated..."] [tasks.compile-if-modified] condition = { files_modified = { input = [ "./Cargo.toml", "./src/**/*.rs", ], output = [ "./target/**/makers*", ] } } command = "cargo" args = ["build"] [tasks.test-duckscript-condition] condition_script = [''' #!@duckscript var = set "hello from duckscript" echo ${var} echo %{var} exit 0 '''] script = ''' echo "duckscript condition was met" ''' [tasks.test-and-condition] condition = { condition_type = "And", env_true = [ "TRUE_ENV", "FALSE_ENV", ], env_false = [ "TRUE_ENV", ] } script = ''' echo "condition was met" ''' [tasks.test-or-condition] condition = { condition_type = "Or", env_true = [ "TRUE_ENV", "FALSE_ENV", ], env_false = [ "TRUE_ENV", ] } script = ''' echo "condition was met" ''' [tasks.test-group-or-condition] condition = { condition_type = "GroupOr", env_true = [ "TRUE_ENV", "FALSE_ENV", ], env_false = [ "TRUE_ENV", ] } script = ''' echo "condition was met" '''