Merge pull request #974 from letheanVPN/npm-json-update

Adding name and author, + json handling improvement
This commit is contained in:
Lea Anthony
2021-11-29 23:48:47 -08:00
committed by GitHub
2 changed files with 6 additions and 5 deletions

View File

@@ -1,4 +1,6 @@
{
"name": "{{.ProjectName}}",
"author": "",
"private": true,
"scripts": {
"install": "go install github.com/wailsapp/wails/v2/cmd/wails@latest",

View File

@@ -158,18 +158,17 @@ func processPackageJSON(frontendDir string) error {
return nil
}
data, err := os.ReadFile(packageJSON)
json, err := os.ReadFile(packageJSON)
if err != nil {
return err
}
json := string(data)
// We will ignore these errors - it's not critical
println("Updating package.json data...")
json, _ = sjson.Set(json, "name", "{{.ProjectName}}")
json, _ = sjson.Set(json, "author", "{{.AuthorName}}")
json, _ = sjson.SetBytes(json, "name", "{{.ProjectName}}")
json, _ = sjson.SetBytes(json, "author", "{{.AuthorName}}")
err = os.WriteFile(packageJSON, []byte(json), 0644)
err = os.WriteFile(packageJSON, json, 0644)
if err != nil {
return err
}