Skip to content

Commit

Permalink
use ~ prefix for dependency replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
WeidiDeng committed May 29, 2024
1 parent 12718b9 commit 69e93ba
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,20 @@ func runBuild(ctx context.Context, args []string) error {
return err
}
mod = strings.TrimSuffix(mod, "/") // easy to accidentally leave a trailing slash if pasting from a URL, but is invalid for Go modules
plugins = append(plugins, xcaddy.Dependency{
PackagePath: mod,
Version: ver,
})
if repl != "" {
// prefix ~ for dependencies
mod, isDep := strings.CutPrefix(mod, "~")
if !isDep {
plugins = append(plugins, xcaddy.Dependency{
PackagePath: mod,
Version: ver,
})
}
if repl == "" {
// dependencies should have a replacement, or else there is no need to specify it
if isDep {
return fmt.Errorf("missing replacement for dependency %s", mod)
}
} else {
// adjust relative replacements in current working directory since our temporary module is in a different directory
if strings.HasPrefix(repl, ".") {
repl, err = filepath.Abs(repl)
Expand Down

0 comments on commit 69e93ba

Please sign in to comment.