Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit b45a4b8

Browse files
committed
cmd/gon: shuffle some logic to be a bit clearer
1 parent b86987e commit b45a4b8

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

cmd/gon/main.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,7 @@ func realMain() int {
7979
// request per file here.
8080
var items []*item
8181

82-
// Notarize is an alternative to "Source", where you specify
83-
// a single .pkg or .zip that is ready for notarization and stapling
84-
if len(cfg.Notarize) > 0 {
85-
for _, c := range cfg.Notarize {
86-
items = append(items, &item{
87-
Path: c.Path,
88-
BundleId: c.BundleId,
89-
Staple: c.Staple,
90-
})
91-
}
92-
}
93-
82+
// A bunch of validation
9483
if len(cfg.Source) > 0 {
9584
if cfg.Sign == nil {
9685
color.New(color.Bold, color.FgRed).Fprintf(os.Stdout,
@@ -101,6 +90,14 @@ func realMain() int {
10190
return 1
10291
}
10392
} else {
93+
if len(cfg.Notarize) == 0 {
94+
color.New(color.Bold, color.FgRed).Fprintf(os.Stdout, "❗️ No source files specified\n")
95+
color.New(color.FgRed).Fprintf(os.Stdout,
96+
"Your configuration had an empty 'source' and empty 'notarize' values. This must be populated with\n"+
97+
"at least one file to sign, package, and notarize.\n")
98+
return 1
99+
}
100+
104101
if cfg.Zip != nil {
105102
color.New(color.Bold, color.FgRed).Fprintf(os.Stdout,
106103
"❗️ `zip` can only be set while `source` is also set\n")
@@ -122,13 +119,16 @@ func realMain() int {
122119
}
123120
}
124121

125-
// If we have no items to sign then its probably an error
126-
if len(cfg.Source) == 0 && len(cfg.Notarize) == 0 {
127-
color.New(color.Bold, color.FgRed).Fprintf(os.Stdout, "❗️ No source files specified\n")
128-
color.New(color.FgRed).Fprintf(os.Stdout,
129-
"Your configuration had an empty 'source' and empty 'notarize' values. This must be populated with\n"+
130-
"at least one file to sign, package, and notarize.\n")
131-
return 1
122+
// Notarize is an alternative to "Source", where you specify
123+
// a single .pkg or .zip that is ready for notarization and stapling
124+
if len(cfg.Notarize) > 0 {
125+
for _, c := range cfg.Notarize {
126+
items = append(items, &item{
127+
Path: c.Path,
128+
BundleId: c.BundleId,
129+
Staple: c.Staple,
130+
})
131+
}
132132
}
133133

134134
// If we're in source mode, then sign & package as configured

0 commit comments

Comments
 (0)