Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Negative Conditions for Environment Variables #1185

Open
ayodejiige opened this issue Nov 9, 2024 · 3 comments · May be fixed by #1187
Open

Enable Negative Conditions for Environment Variables #1185

ayodejiige opened this issue Nov 9, 2024 · 3 comments · May be fixed by #1187
Assignees

Comments

@ayodejiige
Copy link

ayodejiige commented Nov 9, 2024

Feature Description

Enable conditions for scripts where an environment variable is not a particular value.

Describe The Solution You'd Like

There are cases where you might want to run a task only when an environment variable does not equal a particular value. This does not seem possible with the current options.

Code Sample

[tasks.build-if-not-blue]
command = "cargo"
args = ["build"]
condition = { env_not = {  "COLOR" = "blue" } }
@sagiegurari
Copy link
Owner

there is actually env_not_set, env_false and files_not_exist but i guess you are talking about having a env_not to be the opposite of env. so that i do not have but its easy to add.
would you like to PR that?

@sagiegurari
Copy link
Owner

also there is a workaround currently with using run_task with criteria and a default

@ayodejiige
Copy link
Author

ayodejiige commented Nov 12, 2024

@sagiegurari I can make a PR for it. Is this what you mean by the workaround?

[tasks.build]
command = "cargo"
args = ["build"]

[tasks.build-if-not-blue]
run_task = [
    { name = "default", condition = { env = { "COLOR" = "blue" } } },
    { name = "build" }
]

@ayodejiige ayodejiige linked a pull request Nov 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants