Add support for environment variable expansion in dependencies

This commit is contained in:
Lucas Bremgartner 2017-06-30 12:01:37 +02:00
parent 87f1a4e15c
commit e2474969bd
2 changed files with 7 additions and 5 deletions

View File

@ -248,11 +248,11 @@ itself) in the `links` block; you can read more about how to use environment var
### Environment Variables ###
Homemaker supports the expansion of environment variables for both command and link blocks. This is a good way of
avoiding having to hard code absolute paths into your configuration file. To reference an environment variable simply
use `${ENVVAR}` or `$ENVVAR`, where `ENVVAR` is the variable name (notice the similarity to normal shell variable
expansion). In addition to being able to reference all of the environment variables defined on your system, Homemaker
defines a couple of extra ones for ease of use:
Homemaker supports the expansion of environment variables for both command and link blocks as well as for dependencies.
This is a good way of avoiding having to hard code absolute paths into your configuration file. To reference an
environment variable simply use `${ENVVAR}` or `$ENVVAR`, where `ENVVAR` is the variable name (notice the similarity
to normal shell variable expansion). In addition to being able to reference all of the environment variables defined
on your system, Homemaker defines a couple of extra ones for ease of use:
* `HM_CONFIG`

View File

@ -25,6 +25,7 @@ package main
import (
"fmt"
"log"
"os"
)
type task struct {
@ -52,6 +53,7 @@ func (t *task) deps(conf *config) []string {
func (t *task) process(conf *config) error {
for _, currTask := range t.deps(conf) {
currTask = os.ExpandEnv(currTask)
if err := processTask(currTask, conf); err != nil {
return err
}