mirror of
https://github.com/caddyserver/xcaddy.git
synced 2025-03-24 14:14:52 +01:00
Resolve relative replacements
This allows us to use user-defined replacements that have a relative path, since our temporary modules exist in different dirs.
This commit is contained in:
parent
a9fc1ead03
commit
623c361726
1 changed files with 9 additions and 5 deletions
|
@ -186,10 +186,14 @@ func runDev(ctx context.Context, args []string) error {
|
||||||
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
|
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
replacements = append(replacements, xcaddy.NewReplace(
|
|
||||||
strings.TrimSpace(parts[0]),
|
// adjust relative replacements in original module since our temporary module is in a different directory
|
||||||
strings.TrimSpace(parts[1]),
|
if !filepath.IsAbs(parts[1]) {
|
||||||
))
|
parts[1] = filepath.Join(moduleDir, parts[1])
|
||||||
|
log.Printf("[INFO] Resolved relative replacement %s to %s", line, parts[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
replacements = append(replacements, xcaddy.NewReplace(parts[0], parts[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
// reconcile remaining path segments; for example if a module foo/a
|
// reconcile remaining path segments; for example if a module foo/a
|
||||||
|
|
Loading…
Add table
Reference in a new issue