github.com/drone/runner-go@v1.12.0/environ/expand.go (about)

     1  // Copyright 2019 Drone.IO Inc. All rights reserved.
     2  // Use of this source code is governed by the Polyform License
     3  // that can be found in the LICENSE file.
     4  
     5  package environ
     6  
     7  import "os"
     8  
     9  // function used to expand environment variables.
    10  var getenv = os.Getenv
    11  
    12  // Expand is a helper function to expand the PATH parameter in
    13  // the pipeline environment.
    14  func Expand(env map[string]string) map[string]string {
    15  	c := map[string]string{}
    16  	for k, v := range env {
    17  		c[k] = v
    18  	}
    19  	if path := c["PATH"]; path != "" {
    20  		c["PATH"] = os.Expand(path, getenv)
    21  	}
    22  	return c
    23  }