// copyElectronApplication from library package to defined app directory.
// copy app files (.js .css) to app directory
//
// forceInstall forces a reinstallation of electron
// and resets AppDirectory/assets if no UIFolder was set.
//
// On the first run we copy a default application
// into AppDirectory and install electronjs locally.
// When a ui directory was set we use the contents of those
// and copy it into AppDirectory/assets
copyElectronApplication from library package to defined app directory.
copy app files (.js .css) to app directory

forceInstall forces a reinstallation of electron
and resets AppDirectory/assets if no UIFolder was set.

On the first run we copy a default application
into AppDirectory and install electronjs locally.
When a ui directory was set we use the contents of those
and copy it into AppDirectory/assets
// copyElectronApplication from library package to defined app directory . // copy app files ( . js . css ) to app directory // // forceInstall forces a reinstallation of electron // and resets AppDirectory / assets if no UIFolder was set . // // On the first run we copy a default application // into AppDirectory and install electronjs locally . // When a ui directory was set we use the contents of those // and copy it into AppDirectory / assets
func (gbw *BrowserWindow) copyElectronApplication(forceInstall bool) (err error) {
	defer errz.Recover(&err)
	mainJS := filepath.Join(gbw.AppDirectory, "main.js")
	firstRun := !file.Exists(mainJS)
	_, filename, _, ok := runtime.Caller(0)
	if !ok {
		return errors.New("No caller information")
	}
	gbwDirectory := filepath.Dir(filename)
	if firstRun || forceInstall {
		templateDir := filepath.Join(gbwDirectory, templateApplicationDir)
		err = copy.Copy(templateDir, gbw.AppDirectory)
		errz.Fatal(err)
	}
	err = os.Chmod(gbw.AppDirectory, gotronFileMode)
	errz.Fatal(err)
	assetsDir := filepath.Join(gbw.AppDirectory, "assets")
	err = os.Chmod(assetsDir, gotronFileMode)
	errz.Fatal(err)
	if gbw.UIFolder == "" {
		return
	}
	html := filepath.Join(gbw.UIFolder, "index.html")
	htm := filepath.Join(gbw.UIFolder, "index.htm")
	if !(file.Exists(html) || file.Exists(htm)) {
		return fmt.Errorf("index.htm(l) missing in %s", gbw.UIFolder)
	}
	src, err := filepath.Abs(gbw.UIFolder)
	errz.Fatal(err)
	dst, err := filepath.Abs(filepath.Join(gbw.AppDirectory, "assets"))
	errz.Fatal(err)
	if src != dst {
		err = os.RemoveAll(filepath.Join(gbw.AppDirectory, "assets"))
		errz.Fatal(err)
		err = copy.Copy(gbw.UIFolder, filepath.Join(gbw.AppDirectory, "assets"))
		errz.Fatal(err)
	}
	return nil
}
func ( gbw * BrowserWindow ) copyElectronApplication ( forceInstall bool ) ( err error ) { defer errz . Recover ( & err ) mainJS := filepath . Join ( gbw . AppDirectory , " " ) firstRun := ! file . Exists ( mainJS ) _ , filename , _ , ok := runtime . Caller ( 0 ) if ! ok { return errors . New ( " " ) } gbwDirectory := filepath . Dir ( filename ) if firstRun || forceInstall { templateDir := filepath . Join ( gbwDirectory , templateApplicationDir ) err = copy . Copy ( templateDir , gbw . AppDirectory ) errz . Fatal ( err ) } err = os . Chmod ( gbw . AppDirectory , gotronFileMode ) errz . Fatal ( err ) assetsDir := filepath . Join ( gbw . AppDirectory , " " ) err = os . Chmod ( assetsDir , gotronFileMode ) errz . Fatal ( err ) if gbw . UIFolder == " " { return } html := filepath . Join ( gbw . UIFolder , " " ) htm := filepath . Join ( gbw . UIFolder , " " ) if ! ( file . Exists ( html ) || file . Exists ( htm ) ) { return fmt . Errorf ( " " , gbw . UIFolder ) } src , err := filepath . Abs ( gbw . UIFolder ) errz . Fatal ( err ) dst , err := filepath . Abs ( filepath . Join ( gbw . AppDirectory , " " ) ) errz . Fatal ( err ) if src != dst { err = os . RemoveAll ( filepath . Join ( gbw . AppDirectory , " " ) ) errz . Fatal ( err ) err = copy . Copy ( gbw . UIFolder , filepath . Join ( gbw . AppDirectory , " " ) ) errz . Fatal ( err ) } return nil }
copyElectronApplication from library package to defined app directory.
copyElectronApplication from library package to defined app directory .
// Copy app Directory // If no UI folder is set use default ui files // UIFolder must contain a index.htm(l) // No need to copy web application files // when no ui folder is set. // Also check for ".gotron/assets". This is the // default directory when called from gotron-builder, // avoids deleting asset dir by accident.