fix(v3): fix macOS mkdir brace expansion when APP_NAME contains spaces (#4850)

fix(v3): fix macOS mkdir when APP_NAME contains spaces

Replace brace expansion {MacOS,Resources} with two separate mkdir commands.
Brace expansion doesn't work inside quoted strings and is shell-dependent.

Adds integration test to verify mkdir works with spaces in paths.
This commit is contained in:
Lea Anthony 2026-01-04 15:48:03 +11:00 committed by GitHub
commit ee7e95af52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 6 deletions

View file

@ -29,6 +29,7 @@ After processing, the content will be moved to the main changelog and this file
- Fix file drop coordinates being in wrong pixel space on Windows (physical vs CSS pixels)
- Fix file drag-and-drop on Linux not working reliably with hover effects
- Fix HTML5 internal drag-and-drop being broken when file drop was enabled on Linux
- Fix macOS app bundle creation failing when APP_NAME contains spaces (brace expansion issue)
## Deprecated
<!-- Soon-to-be removed features -->

View file

@ -138,7 +138,8 @@ tasks:
create:app:bundle:
summary: Creates an `.app` bundle
cmds:
- mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/{MacOS,Resources}"
- mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS"
- mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources"
- cp build/darwin/icons.icns "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources"
- cp "{{.BIN_DIR}}/{{.APP_NAME}}" "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS"
- cp build/darwin/Info.plist "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents"
@ -158,7 +159,8 @@ tasks:
run:
cmds:
- mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/{MacOS,Resources}"
- mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS"
- mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Resources"
- cp build/darwin/icons.icns "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Resources"
- cp "{{.BIN_DIR}}/{{.APP_NAME}}" "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS"
- cp "build/darwin/Info.dev.plist" "{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Info.plist"

View file

@ -4,6 +4,7 @@ import (
"bytes"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
@ -156,8 +157,8 @@ func TestCLIParameterFormats(t *testing.T) {
},
},
{
name: "Empty value",
otherArgs: []string{"build", "EMPTY=", "KEY=value"},
name: "Empty value",
otherArgs: []string{"build", "EMPTY=", "KEY=value"},
expectedVars: map[string]string{
"EMPTY": "",
"KEY": "value",
@ -224,7 +225,7 @@ func captureTaskOutput(t *testing.T, options *RunTaskOptions, otherArgs []string
// Wait for task to complete
<-done
// Check for errors (might be expected in some tests)
if taskErr != nil && !strings.Contains(taskErr.Error(), "expected") {
t.Logf("Task error (might be expected): %v", taskErr)
@ -286,4 +287,56 @@ func TestBackwardCompatibility(t *testing.T) {
}
})
}
}
}
func TestMkdirWithSpacesInPath(t *testing.T) {
if runtime.GOOS != "darwin" {
t.Skip("Skipping: macOS app bundle test only applies to darwin")
}
if os.Getenv("CI") == "true" && os.Getenv("SKIP_INTEGRATION_TESTS") == "true" {
t.Skip("Skipping integration test in CI")
}
tmpDir, err := os.MkdirTemp("", "wails task test with spaces-*")
require.NoError(t, err)
defer os.RemoveAll(tmpDir)
taskfileContent := `version: '3'
vars:
BIN_DIR: "` + tmpDir + `/bin"
APP_NAME: "My App"
tasks:
create-bundle:
cmds:
- mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS"
- mkdir -p "{{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources"
`
taskfilePath := filepath.Join(tmpDir, "Taskfile.yml")
err = os.WriteFile(taskfilePath, []byte(taskfileContent), 0644)
require.NoError(t, err)
originalWd, err := os.Getwd()
require.NoError(t, err)
defer os.Chdir(originalWd)
err = os.Chdir(tmpDir)
require.NoError(t, err)
err = RunTask(&RunTaskOptions{Name: "create-bundle"}, []string{})
require.NoError(t, err)
appContentsDir := filepath.Join(tmpDir, "bin", "My App.app", "Contents")
macOSDir := filepath.Join(appContentsDir, "MacOS")
info, err := os.Stat(macOSDir)
require.NoError(t, err, "MacOS directory should exist")
assert.True(t, info.IsDir(), "MacOS should be a directory")
resourcesDir := filepath.Join(appContentsDir, "Resources")
info, err = os.Stat(resourcesDir)
require.NoError(t, err, "Resources directory should exist")
assert.True(t, info.IsDir(), "Resources should be a directory")
}