github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/install/install_darwinwindows.go (about)

     1  // Copyright 2018 Keybase, Inc. All rights reserved. Use of
     2  // this source code is governed by the included BSD license.
     3  
     4  //go:build darwin || windows
     5  // +build darwin windows
     6  
     7  package install
     8  
     9  import (
    10  	"os/exec"
    11  	"strconv"
    12  	"strings"
    13  )
    14  
    15  // GetNeedUpdate returns true if updater says we have a new update available.
    16  // This runs `updater need-update`, which ignores the snooze.
    17  func GetNeedUpdate() (bool, error) {
    18  	updaterPath, err := UpdaterBinPath()
    19  	if err != nil {
    20  		return false, err
    21  	}
    22  	cmd := exec.Command(updaterPath, "need-update")
    23  	out, err := cmd.Output()
    24  	if err != nil {
    25  		return false, err
    26  	}
    27  	needUpdate, err := strconv.ParseBool(strings.TrimSpace(string(out)))
    28  	if err != nil {
    29  		return false, err
    30  	}
    31  	return needUpdate, nil
    32  }