💅 tweak update notifier
This commit is contained in:
parent
78b67fabdd
commit
ce8f37aca2
2 changed files with 14 additions and 4 deletions
|
|
@ -186,9 +186,17 @@ func printError(out io.Writer, err error, cmd *cobra.Command, debug bool) {
|
|||
}
|
||||
|
||||
func shouldCheckForUpdate() bool {
|
||||
isCIEnvironment := (os.Getenv("CI") != "") || (os.Getenv("BUILD_NUMBER") != "") || (os.Getenv("RUN_ID") != "")
|
||||
isGlobalDisabled := os.Getenv("GH_NO_UPDATE_NOTIFIER") != ""
|
||||
return updaterEnabled != "" && !isCompletionCommand() && utils.IsTerminal(os.Stderr) && !isCIEnvironment && !isGlobalDisabled
|
||||
if os.Getenv("GH_NO_UPDATE_NOTIFIER") != "" {
|
||||
return false
|
||||
}
|
||||
return updaterEnabled != "" && !isCI() && !isCompletionCommand() && utils.IsTerminal(os.Stderr)
|
||||
}
|
||||
|
||||
// based on https://github.com/watson/ci-info/blob/HEAD/index.js
|
||||
func isCI() bool {
|
||||
return os.Getenv("CI") != "" || // GitHub Actions, Travis CI, CircleCI, Cirrus CI, GitLab CI, AppVeyor, CodeShip, dsari
|
||||
os.Getenv("BUILD_NUMBER") != "" || // Jenkins, TeamCity
|
||||
os.Getenv("RUN_ID") != "" // TaskCluster, dsari
|
||||
}
|
||||
|
||||
func isCompletionCommand() bool {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ func NewHelpTopic(topic string) *cobra.Command {
|
|||
CLICOLOR_FORCE: set to a value other than "0" to keep ANSI colors in output
|
||||
even when the output is piped.
|
||||
|
||||
GH_NO_UPDATE_NOTIFIER: set to "1" to disable checking for updates.
|
||||
GH_NO_UPDATE_NOTIFIER: set to any value to disable update notifications. By default, gh
|
||||
checks for new releases once every 24 hours and displays an upgrade notice on standard
|
||||
error if a newer version was found.
|
||||
`)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue