add sources option

This commit is contained in:
Shane C 2024-07-04 18:08:45 -04:00
parent 0c1ffa1cd9
commit 76f276f69e
Signed by: shane
GPG key ID: E46B5FEA35B22FF9
2 changed files with 7 additions and 2 deletions

View file

@ -10,7 +10,7 @@ type LinuxCommand struct {
type CommandOptions struct { type CommandOptions struct {
Env map[string]string Env map[string]string
Sources map[string]string Sources []string
Command string Command string
Args []string Args []string
Cwd string Cwd string

View file

@ -29,7 +29,12 @@ func NewCommand(options CommandOptions) (*LinuxCommand, error) {
func (cmd *LinuxCommand) Run() error { func (cmd *LinuxCommand) Run() error {
command := exec.Command(cmd.Options.Shell, "--rcfile", "testrc", "-c", cmd.Options.Command) var sourceCommand string
for _, value := range cmd.Options.Sources {
sourceCommand += fmt.Sprintf("source %s && ", value)
}
command := exec.Command(cmd.Options.Shell, "-c", sourceCommand+cmd.Options.Command)
command.Dir = cmd.Options.Cwd command.Dir = cmd.Options.Cwd
command.Args = append(command.Args, cmd.Options.Args...) command.Args = append(command.Args, cmd.Options.Args...)