52 lines
1.5 KiB
Go
Executable File
52 lines
1.5 KiB
Go
Executable File
/*
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
package electron
|
|
|
|
import (
|
|
"log"
|
|
"os/exec"
|
|
"syscall"
|
|
)
|
|
|
|
// RunElectron executes the standalone electron app which serves up our web components
|
|
func RunElectron() {
|
|
cmd := exec.Command("npm", "start", "--prefix", "web")
|
|
|
|
// make sure the logs are coming out of electron app
|
|
//cmd.Stdout = os.Stdout
|
|
// cmd.Stderr = os.Stderr
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
if exitError, ok := err.(*exec.ExitError); ok {
|
|
log.Fatalf("Exit with error: %v", exitError)
|
|
}
|
|
}
|
|
|
|
if err := cmd.Wait(); err != nil {
|
|
if exiterr, ok := err.(*exec.ExitError); ok {
|
|
// The program has exited with an exit code != 0
|
|
|
|
// This works on both Unix and Windows. Although package
|
|
// syscall is generally platform dependent, WaitStatus is
|
|
// defined for both Unix and Windows and in both cases has
|
|
// an ExitStatus() method with the same signature.
|
|
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
|
|
log.Printf("Exit Status: %d", status.ExitStatus())
|
|
}
|
|
} else {
|
|
log.Fatalf("Electron app close detected, exiting")
|
|
}
|
|
}
|
|
}
|