Skip to content

Commit a9bec28

Browse files
committed
Change Info to Error if excluding-platform, when platforms is present for this package
1 parent 577032b commit a9bec28

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

internal/devconfig/packages.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ package devconfig
22

33
import (
44
"encoding/json"
5-
"os"
6-
"strings"
75

86
"github.com/pkg/errors"
97
"github.com/samber/lo"
108
orderedmap "github.com/wk8/go-ordered-map/v2"
9+
"go.jetpack.io/devbox/internal/boxcli/usererr"
1110
"go.jetpack.io/devbox/internal/nix"
1211
"go.jetpack.io/devbox/internal/searcher"
13-
"go.jetpack.io/devbox/internal/ux"
1412
"golang.org/x/exp/slices"
1513
)
1614

@@ -106,12 +104,10 @@ func (pkgs *Packages) ExcludePlatforms(versionedName string, platforms []string)
106104

107105
pkg.ExcludedPlatforms = lo.Uniq(append(pkg.ExcludedPlatforms, platforms...))
108106
if len(pkg.Platforms) > 0 {
109-
ux.Finfo(
110-
os.Stderr,
111-
"Excluding a platform for %[1]s is a bit redundant because it will only be installed on: %[2]v. "+
112-
"Consider removing the `platform` field from %[1]s's definition in your devbox."+
113-
"json if you intend for %[1]s to be installed on all platforms except %[3]s.\n",
114-
versionedName, strings.Join(pkg.Platforms, ", "), strings.Join(platforms, ", "),
107+
return usererr.New(
108+
"cannot exclude any platform for package %s because it already has `platforms` defined. "+
109+
"Please delete the `platforms` for this package from devbox.json and re-try.",
110+
pkg.VersionedName(),
115111
)
116112
}
117113

0 commit comments

Comments
 (0)