Skip to content

Commit

Permalink
Update README: expand envvars section
Browse files Browse the repository at this point in the history
  • Loading branch information
kenden authored and qnerden committed Feb 4, 2022
1 parent 027115f commit ad1d2e1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ The executable is at: /bin/just

==== Dotenv Integration

`just` will load environment variables from a file named `.env`. This file can be located in the same directory as your justfile or in a parent directory. These variables are environment variables, not `just` variables, and so must be accessed using `$VARIABLE_NAME` in recipes and backticks.
`just` will load environment variables from a file named `.env` if the setting [dotenv-load](https://github.com/casey/just#dotenv-load) is present. This file can be located in the same directory as your justfile or in a parent directory. These variables are environment variables, not `just` variables, and so must be accessed using `$VARIABLE_NAME` in recipes and backticks.

For example, if your `.env` file contains:

Expand Down Expand Up @@ -1126,6 +1126,12 @@ $ just --set os bsd

=== Environment Variables

==== How to pass environment variables to recipes

There are two ways to pass environment variables to recipes: exporting `just` variables, or using an `.env` file.

===== Exporting `just` variables

Assignments prefixed with the `export` keyword will be exported to recipes as environment variables:

```make
Expand Down Expand Up @@ -1158,6 +1164,17 @@ a $A $B=`echo $A`:
echo $A $B
```

Note: the setting link:README.adoc#export[export] causes all `just` variables to be exported to recipes as enviroment variables.

===== Using an `.env` file

`just` can load an .env file if the setting link:README.adoc#dotenv-load[dotenv-load] is present. The variables in the file will be available as environment variables to the recipes. See link:README.adoc#dotenv-integration[here] for more information.

==== Loading `just` variables from the shell environments variables

Environment variables from the shell can be loaded as variables in `just` with the functions `env_var()` and `en_var_or_default()`, described link:README.adoc#environment-variables[here].
They could then be exported to the recipes using link:README.adoc#exporting-just-variables[export].

=== Recipe Parameters

Recipes may have parameters. Here recipe `build` has a parameter called `target`:
Expand Down

0 comments on commit ad1d2e1

Please sign in to comment.