mirror of
https://github.com/caddyserver/xcaddy.git
synced 2024-11-05 00:40:24 +00:00
execute module replacement in a single command (#178)
* execute module replacement in a single command * remove empty line
This commit is contained in:
parent
dcaaa7302c
commit
743ce51c13
1 changed files with 7 additions and 3 deletions
|
@ -144,13 +144,17 @@ func (b Builder) newEnvironment(ctx context.Context) (*environment, error) {
|
|||
replaced := make(map[string]string)
|
||||
for _, r := range b.Replacements {
|
||||
log.Printf("[INFO] Replace %s => %s", r.Old.String(), r.New.String())
|
||||
cmd := env.newGoModCommand(ctx, "edit",
|
||||
"-replace", fmt.Sprintf("%s=%s", r.Old.Param(), r.New.Param()))
|
||||
replaced[r.Old.String()] = r.New.String()
|
||||
}
|
||||
if len(replaced) > 0 {
|
||||
cmd := env.newGoModCommand(ctx, "edit")
|
||||
for o, n := range replaced {
|
||||
cmd.Args = append(cmd.Args, "-replace", fmt.Sprintf("%s=%s", o, n))
|
||||
}
|
||||
err := env.runCommand(ctx, cmd)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
replaced[r.Old.String()] = r.New.String()
|
||||
}
|
||||
|
||||
// check for early abort
|
||||
|
|
Loading…
Reference in a new issue