func generateWindowsUpdateScript()

in fast-build-update-tool/internal/tools/update_script_generator_windows_fleet.go [14:34]


func generateWindowsUpdateScript(writer io.Writer, executablePaths []string, localBuildZipPath, lockName string, updateOperation config.UpdateOperation) error {
	template, err := template.New("windows-update-template").Parse(windowsUpdateScriptTemplate)
	if err != nil {
		return err
	}

	processNames := make([]string, len(executablePaths))
	for i, executablePath := range executablePaths {
		parts := strings.Split(executablePath, "\\")
		exeName := parts[len(parts)-1]
		processNames[i] = strings.Replace(exeName, ".exe", "", -1)
	}

	return template.Execute(writer, map[string]string{
		"ArchiveName":     filepath.Base(localBuildZipPath),
		"ExecutablePaths": csvify(executablePaths),
		"ProcessNames":    csvify(processNames),
		"IsReplaceBuild":  getIsReplaceBuildTemplateValue(updateOperation),
		"LockName":        lockName,
	})
}