airshipui/internal/electron/app.go
Schiefelbein, Andrew 3122f7355f Update Makefile and documentation for npm installs
Changes:
1. npm electron start is run with local node / npm:
   /<airshipui_root>/tools/node-v12.16.3/bin
2. The Makefile now will install node by default
3. The Makefile will now add the node modules on command
4. Seperated out the go linter and the js linter installers

Change-Id: I03904218082e73ef757e06073b548b9c3f499784
2020-05-29 14:17:38 -05:00

47 lines
1.4 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 (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"syscall"
)
// RunElectron executes the standalone electron app which serves up our web components
func RunElectron() error {
// determine ; or : depending on the OS
sep := string(os.PathListSeparator)
// get the current working directory, should be the root of the airshipui tree
path, err := os.Getwd()
if err != nil {
log.Println(err)
}
// TODO: make the node path dynamic or setable at compile time
os.Setenv("PATH", filepath.Join(path+"/tools/node-v12.16.3/bin")+sep+os.Getenv("PATH"))
// This should start the electron app with the internal npm & node binaries
cmd := exec.Command("npm", "start", "--prefix", "web")
if err := cmd.Run(); err != nil {
return fmt.Errorf("electron %d", err.(*exec.ExitError).Sys().(syscall.WaitStatus).ExitStatus())
}
return nil
}