Merge pull request #1509 from harshavardhana/update
update: Fix update command.
This commit is contained in:
+3
-3
@@ -35,14 +35,14 @@ func colorizeUpdateMessage(updateString string) (string, *probe.Error) {
|
||||
|
||||
// calculate length without color coding, due to ANSI color characters padded to actual
|
||||
// string the final length is wrong than the original string length.
|
||||
line1Str := fmt.Sprintf(" Update available: ")
|
||||
line2Str := fmt.Sprintf(" Run \"%s\" to update. ", updateString)
|
||||
line1Str := fmt.Sprintf(" New update available, please execute the following command to update: ")
|
||||
line2Str := fmt.Sprintf(" %s ", updateString)
|
||||
line1Length := len(line1Str)
|
||||
line2Length := len(line2Str)
|
||||
|
||||
// populate lines with color coding.
|
||||
line1InColor := line1Str
|
||||
line2InColor := fmt.Sprintf(" Run \"%s\" to update. ", cyan(updateString))
|
||||
line2InColor := fmt.Sprintf(" %s ", cyan(updateString))
|
||||
|
||||
// calculate the rectangular box size.
|
||||
maxContentWidth := int(math.Max(float64(line1Length), float64(line2Length)))
|
||||
|
||||
+9
-2
@@ -19,6 +19,7 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
@@ -93,9 +94,15 @@ func (u updateMessage) String() string {
|
||||
}
|
||||
var msg string
|
||||
if runtime.GOOS == "windows" {
|
||||
msg = "mc.exe cp " + u.Download + " .\\mc.exe"
|
||||
// verify if the mc binary exists in the current directory.
|
||||
// In such cases do not overwrite it.
|
||||
if _, e := os.Stat(".\\mc.exe"); e == nil {
|
||||
msg = "Download " + u.Download
|
||||
} else {
|
||||
msg = "mc.exe cp " + u.Download + " .\\mc.exe"
|
||||
}
|
||||
} else {
|
||||
msg = "mc cp " + u.Download + " ./mc.new; chmod 755 ./mc.new"
|
||||
msg = "mc cp " + u.Download + " mc; chmod 755 mc"
|
||||
}
|
||||
msg, err := colorizeUpdateMessage(msg)
|
||||
fatalIf(err.Trace(msg), "Unable to colorize experimental update notification string ‘"+msg+"’.")
|
||||
|
||||
Reference in New Issue
Block a user