// This function determines if the main.js file using wailsbridge can be auto-updated
This function determines if the main.js file using wailsbridge can be auto-updated
// This function determines if the main . js file using wailsbridge can be auto - updated
func checkMainJS() (bool, error) {
	checkSpinner.Start("Checking if main.js can be migrated")
	var err error
	if migrateProjectOptions.FrontEnd == nil ||
		len(migrateProjectOptions.FrontEnd.Dir) == 0 ||
		!migrateFS.DirExists(migrateProjectOptions.FrontEnd.Dir) {
		checkSpinner.Error("Unable to determine frontend directory")
		return false, fmt.Errorf("Unable to determine frontend directory")
	}
	frontEndDir = migrateProjectOptions.FrontEnd.Dir
	mainJSFile, err = filepath.Abs(filepath.Join(".", frontEndDir, "src", "main.js"))
	if err != nil {
		checkSpinner.Error("Unable to find main.js")
		return false, err
	}
	mainJSContents, err = migrateFS.LoadAsString(mainJSFile)
	if err != nil {
		checkSpinner.Error("Unable to load main.js")
		return false, err
	}
	if strings.Index(mainJSContents, `import Bridge from "./wailsbridge";`) == -1 {
		checkSpinner.Success("Checking if main.js can be migrated: No - Cannot find `import Bridge`")
		return false, nil
	}
	if strings.Index(mainJSContents, `Bridge.Start(`) == -1 {
		checkSpinner.Success("Checking if main.js can be migrated: No - Cannot find `Bridge.Start`")
		return false, nil
	}
	checkSpinner.Success("Checking if main.js can be migrated: Yes")
	return true, nil
}
func checkMainJS ( ) ( bool , error ) { checkSpinner . Start ( " " ) var err error if migrateProjectOptions . FrontEnd == nil || len ( migrateProjectOptions . FrontEnd . Dir ) == 0 || ! migrateFS . DirExists ( migrateProjectOptions . FrontEnd . Dir ) { checkSpinner . Error ( " " ) return false , fmt . Errorf ( " " ) } frontEndDir = migrateProjectOptions . FrontEnd . Dir mainJSFile , err = filepath . Abs ( filepath . Join ( " " , frontEndDir , " " , " " ) ) if err != nil { checkSpinner . Error ( " " ) return false , err } mainJSContents , err = migrateFS . LoadAsString ( mainJSFile ) if err != nil { checkSpinner . Error ( " " ) return false , err } if strings . Index ( mainJSContents , `import Bridge from "./wailsbridge";` ) == - 1 { checkSpinner . Success ( " " ) return false , nil } if strings . Index ( mainJSContents , `Bridge.Start(` ) == - 1 { checkSpinner . Success ( " " ) return false , nil } checkSpinner . Success ( " " ) return true , nil }
This function determines if the main.js file using wailsbridge can be auto-updated
This function determines if the main . js file using wailsbridge can be auto - updated
// Check main.js is there // Check we have a line like: import Bridge from "./wailsbridge"; // Check we have a line like: Bridge.Start(() => {