Move to it's own package
This commit is contained in:
parent
30bfca0a2a
commit
e95594675d
2 changed files with 7 additions and 5 deletions
3
main.go
3
main.go
|
|
@ -6,11 +6,12 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/github/gh-cli/command"
|
||||
"github.com/github/gh-cli/update"
|
||||
)
|
||||
|
||||
func main() {
|
||||
printUpdateMessage := make(chan func())
|
||||
go command.CheckForUpdate(printUpdateMessage)
|
||||
go update.CheckForUpdate(printUpdateMessage)
|
||||
|
||||
if cmd, err := command.RootCmd.ExecuteC(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package command
|
||||
package update
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/github/gh-cli/command"
|
||||
"github.com/github/gh-cli/utils"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
|
@ -28,14 +29,14 @@ func CheckForUpdate(handleUpdate chan func()) {
|
|||
handleUpdate <- nil
|
||||
}
|
||||
|
||||
updateAvailable := latestRelease.Version != Version
|
||||
updateAvailable := latestRelease.Version != command.Version
|
||||
|
||||
if updateAvailable {
|
||||
handleUpdate <- func() {
|
||||
fmt.Printf(utils.Cyan(`
|
||||
A new version of gh is available! %s → %s
|
||||
Changelog: %s
|
||||
Run 'brew reinstall gh' to update!`)+"\n\n", Version, latestRelease.Version, latestRelease.URL)
|
||||
Run 'brew reinstall gh' to update!`)+"\n\n", command.Version, latestRelease.Version, latestRelease.URL)
|
||||
}
|
||||
} else {
|
||||
handleUpdate <- nil
|
||||
|
|
@ -57,5 +58,5 @@ func getLatestRelease() (*releaseInfo, error) {
|
|||
|
||||
var r releaseInfo
|
||||
json.Unmarshal(data, &r)
|
||||
return r, nil
|
||||
return &r, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue