From 514059e990b0e27e17d078fd84a9d817fcd28e84 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 21 Oct 2019 13:57:26 -0400 Subject: [PATCH 1/3] Separate standard lib imports from remote imports --- mage.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mage.go b/mage.go index 1cb2fcd..c9346e4 100644 --- a/mage.go +++ b/mage.go @@ -5,12 +5,13 @@ package main import ( "encoding/json" "fmt" - "github.com/magefile/mage/mg" - "github.com/magefile/mage/sh" "io/ioutil" "net/http" "os" "strings" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" ) // emoji related constants From dbf53680e61df88d391b47aaff56b9adff99147f Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 21 Oct 2019 14:58:26 -0400 Subject: [PATCH 2/3] Download package updates before building --- mage.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mage.go b/mage.go index c9346e4..ff15790 100644 --- a/mage.go +++ b/mage.go @@ -62,8 +62,25 @@ func createEmojiSlice() ([]string, error) { return emojiSlice, nil } +func getRemotePackages() error { + var packages = []string{ + "samhofi.us/x/keybase", + "github.com/awesome-gocui/gocui", + "github.com/magefile/mage/mage", + "github.com/magefile/mage/mg", + "github.com/magefile/mage/sh", + } + for _, p := range packages { + if err := sh.Run("go", "get", "-u", p); err != nil { + return err + } + } + return nil +} + // Build kbtui with emoji lookup support func BuildEmoji() error { + mg.Deps(getRemotePackages) emojis, err := createEmojiSlice() if err != nil { return err @@ -93,6 +110,7 @@ func exit(err error) { // Build kbtui with just the basic commands. func Build() { + mg.Deps(getRemotePackages) if err := sh.Run("go", "build"); err != nil { defer func() { exit(err) @@ -104,6 +122,7 @@ func Build() { // The ShowReactions TypeCommand will print a message in the feed window when // a reaction is received in the current conversation. func BuildShowReactions() { + mg.Deps(getRemotePackages) if err := sh.Run("go", "build", "-tags", "showreactionscmd"); err != nil { defer func() { exit(err) @@ -116,6 +135,7 @@ func BuildShowReactions() { // received in the current conversation. This gets pretty annoying, and // is not recommended. func BuildAutoReact() { + mg.Deps(getRemotePackages) if err := sh.Run("go", "build", "-tags", "autoreactcmd"); err != nil { defer func() { exit(err) @@ -125,6 +145,7 @@ func BuildAutoReact() { // Build kbtui with all commands and TypeCommands disabled. func BuildAllCommands() { + mg.Deps(getRemotePackages) if err := sh.Run("go", "build", "-tags", "allcommands"); err != nil { defer func() { exit(err) @@ -134,6 +155,7 @@ func BuildAllCommands() { // Build kbtui with all Commands and TypeCommands enabled. func BuildAllCommandsT() { + mg.Deps(getRemotePackages) if err := sh.Run("go", "build", "-tags", "type_commands,allcommands"); err != nil { defer func() { exit(err) @@ -143,6 +165,7 @@ func BuildAllCommandsT() { // Build kbtui with beta functionality func BuildBeta() { + mg.Deps(getRemotePackages) mg.Deps(BuildEmoji) if err := sh.Run("go", "build", "-tags", "allcommands,showreactionscmd,emojiList,tabcompletion"); err != nil { defer func() { From 14c7f9353a3d823449ea2b23b91eaa7353552c3d Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 21 Oct 2019 14:59:39 -0400 Subject: [PATCH 3/3] Move exit helper func above first build target --- mage.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mage.go b/mage.go index ff15790..5fd0f28 100644 --- a/mage.go +++ b/mage.go @@ -78,6 +78,14 @@ func getRemotePackages() error { return nil } +// proper error reporting and exit code +func exit(err error) { + if err != nil { + fmt.Fprintf(os.Stderr, "%+v\n", err) + os.Exit(1) + } +} + // Build kbtui with emoji lookup support func BuildEmoji() error { mg.Deps(getRemotePackages) @@ -100,14 +108,6 @@ func BuildEmoji() error { return nil } -// proper error reporting and exit code -func exit(err error) { - if err != nil { - fmt.Fprintf(os.Stderr, "%+v\n", err) - os.Exit(1) - } -} - // Build kbtui with just the basic commands. func Build() { mg.Deps(getRemotePackages)