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

Setting env variable if not already set #344

Closed
mmstick opened this issue Dec 23, 2019 · 3 comments
Closed

Setting env variable if not already set #344

mmstick opened this issue Dec 23, 2019 · 3 comments
Assignees
Milestone

Comments

@mmstick
Copy link

mmstick commented Dec 23, 2019

With Make:

prefix ?= /usr/local

Defines that prefix will only be assigned to /usr/local if it has not already been defined.

There doesn't seem to be a way to achieve this here in a reasonable way

@sagiegurari
Copy link
Owner

that's a good idea. I think adding the 'condition' structure to env definition will resolve it and also give you a lot more choices.
so you could do

[env]
prefix = { value = "/usr/local", condition = { env_not_set = [ "prefix" ] } }

and naturally in condition you will have access to all condition capabilities like env value checking, file exists and so on...

@sagiegurari
Copy link
Owner

sagiegurari commented Dec 24, 2019

@mmstick just pushed a change to the 0.24.3 development branch with condition support.
basically it looks like:

PREFER_EXISTING = { value = "new", condition = { env_not_set = ["PREFER_EXISTING"] } }
OVERWRITE_EXISTING = { value = "new", condition = { env_set = ["OVERWRITE_EXISTING"] } }

you can see the docs and example toml file.

@sagiegurari
Copy link
Owner

This is now published in the new cargo-make version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants