Files
sonr/internal/files/embed.go
T

59 lines
1.0 KiB
Go
Raw Normal View History

2024-09-05 01:24:57 -04:00
package files
import (
"context"
_ "embed"
"os"
)
//go:embed vault.wasm
var vaultWasmData []byte
func writeServiceWorkerJS(path string) error {
// Create the service worker file
file, err := os.Create(path)
if err != nil {
return err
}
defer file.Close()
// Write the service worker file to the specified path
err = VaultServiceWorker(kVaultFileName).Render(context.Background(), file)
if err != nil {
return err
}
return nil
}
func writeVaultWASM(path string) error {
// Create the vault file
file, err := os.Create(path)
if err != nil {
return err
}
defer file.Close()
// Write the embedded vault file to the specified path
err = os.WriteFile(file.Name(), vaultWasmData, 0o644)
if err != nil {
return err
}
return nil
}
func writeIndexHTML(path string) error {
// create the index file
file, err := os.Create(path)
if err != nil {
return err
}
defer file.Close()
// write the index file to the specified path
err = IndexHTML().Render(context.Background(), file)
if err != nil {
return err
}
return nil
}