-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
62 lines (51 loc) · 1.86 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//go:generate go install -v github.com/josephspurrier/goversioninfo/cmd/goversioninfo
//go:generate goversioninfo -icon=res/papp.ico -manifest=res/papp.manifest
package main
import (
"os"
"strings"
"github.com/portapps/portapps/v3"
"github.com/portapps/portapps/v3/pkg/log"
"github.com/portapps/portapps/v3/pkg/utl"
)
var (
app *portapps.App
)
func init() {
var err error
// Init app
if app, err = portapps.New("smartgit-portable", "SmartGit"); err != nil {
log.Fatal().Err(err).Msg("Cannot initialize application. See log file for more info.")
}
}
func main() {
utl.CreateFolder(app.DataPath)
app.Process = utl.PathJoin(app.AppPath, "bin", "smartgit.exe")
app.WorkingDir = utl.PathJoin(app.AppPath, "bin")
// create err folder
utl.CreateFolder(app.DataPath, "err")
// create default smartgit.vmoptions if not found
customSmartgitOptionsPath := utl.PathJoin(app.DataPath, "smartgit.vmoptions")
if !utl.Exists(customSmartgitOptionsPath) {
if err := utl.CreateFile(customSmartgitOptionsPath, `-Xmx1024m
-Dsmartgit.disableBugReporting=true
`); err != nil {
log.Fatal().Err(err).Msg("Cannot write default smartgit.vmoptions")
}
}
// override system smartgit.vmoptions
smartgitOptionsPath := utl.PathJoin(app.AppPath, "bin", "smartgit.vmoptions")
if err := utl.CreateFile(smartgitOptionsPath, strings.Replace(`-Dsmartboot.sourceDirectory={{ DATA_PATH }}\.updates
-Dsmartgit.settings={{ DATA_PATH }}\.settings
-Dsmartgit.updateCheck.enabled=false
-Dsmartgit.updateCheck.automatic=false
-XX:ErrorFile={{ DATA_PATH }}\err\hs_err_pid%p.log
-include-options {{ DATA_PATH }}\smartgit.vmoptions
`, "{{ DATA_PATH }}", utl.FormatWindowsPath(app.DataPath), -1)); err != nil {
log.Fatal().Err(err).Msg("Cannot write system smartgit.vmoptions")
}
// set JAVA_HOME
os.Setenv("SMARTGIT_JAVA_HOME", utl.PathJoin(app.AppPath, "jre"))
defer app.Close()
app.Launch(os.Args[1:])
}