Skip to content
This repository was archived by the owner on Nov 8, 2021. It is now read-only.

Commit c83e2a4

Browse files
committed
use commands from secman/tools/constants
1 parent e0be5bd commit c83e2a4

2 files changed

Lines changed: 4 additions & 38 deletions

File tree

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ go 1.13
44

55
require (
66
github.com/briandowns/spinner v1.12.0
7+
github.com/secman-team/secman v0.0.0-20210507183205-8a23a96e5322
78
github.com/secman-team/shell v0.3.1
89
)

v_checker.go

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,20 @@ import (
77
"runtime"
88
"github.com/secman-team/shell"
99
"github.com/briandowns/spinner"
10+
commands "github.com/secman-team/secman/tools/constants"
1011
)
1112

12-
1313
func Checker() {
14-
check_w := `
15-
$releases = "https://api.github.com/repos/secman-team/secman/releases"
16-
17-
$l = (Invoke-WebRequest -Uri $releases -UseBasicParsing | ConvertFrom-Json)[0].tag_name
18-
19-
$c = secman verx
20-
21-
if ($l -ne $c) {
22-
$nr = "there's a new release of secman is avalaible:"
23-
$up = "to upgrade run "
24-
$smu = "sm-upg start"
25-
26-
Write-Host ""
27-
Write-Host -NoNewline $nr -ForegroundColor DarkYellow
28-
Write-Host "$c -> $l" -ForegroundColor DarkCyan
29-
Write-Host -NoNewline $up -ForegroundColor DarkYellow
30-
Write-Host $smu -ForegroundColor DarkCyan
31-
}
32-
`
33-
34-
check_ml := `
35-
l=$(curl --silent "https://api.github.com/repos/secman-team/secman/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
36-
c=$(secman verx | tr -d '\n')
37-
38-
if [ $l != $c ]; then
39-
nr="there's a new release of secman is avalaible:"
40-
up="to upgrade run"
41-
smu="secman upgrade"
42-
43-
echo ""
44-
echo "$nr $c -> $l"
45-
echo "$up $smu"
46-
fi
47-
`
48-
4914
s := spinner.New(spinner.CharSets[11], 100*time.Millisecond)
5015
s.Suffix = " 🔍 Checking for updates..."
5116
s.Start()
5217

5318
err, out, errout := shell.ShellOut("")
5419

5520
if runtime.GOOS == "windows" {
56-
err, out, errout = shell.PWSLOut(check_w)
21+
err, out, errout = shell.PWSLOut(commands.Check_w())
5722
} else {
58-
err, out, errout = shell.ShellOut(check_ml)
23+
err, out, errout = shell.ShellOut(commands.Check_ml())
5924
}
6025

6126
if err != nil {

0 commit comments

Comments
 (0)