Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions v3/UNRELEASED_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ After processing, the content will be moved to the main changelog and this file

## Fixed
<!-- Bug fixes -->
* Fixed variable handling when passing command-line arguments to tasks. CLI variables specified as KEY=VALUE pairs are now properly initialized and propagated throughout task execution.
- Detect NVIDIA GPUs and disable DMA-BUF renderer on Linux in [PR](https://github.com/wailsapp/wails/pull/5295) by @leaanthony
- Fix git PR template to point to the correct feedback URL in [PR](https://github.com/wailsapp/wails/pull/5109) by @wayneforrest
- Fix a family of Windows systray `SetMenu` crashes caused by a broken `DestroyMenu` syscall that was passing four arguments instead of one, so every call returned FALSE and freed nothing. Also release HMENU and HBITMAP handles (including those allocated at runtime via `MenuItem.SetBitmap`) on menu rebuilds, reset stale checkbox/radio maps in `Win32Menu.Update`, and drop a redundant `Update()` call in `systemtray.updateMenu` that doubled allocations. Long-running systray apps no longer leak GDI/USER objects on each menu rebuild.
Expand Down
18 changes: 14 additions & 4 deletions v3/internal/commands/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package commands
import (
"context"
"fmt"
"github.com/wailsapp/wails/v3/internal/term"
"os"
"path/filepath"
"strings"
"time"

"github.com/wailsapp/wails/v3/internal/term"

"github.com/wailsapp/task/v3"
"github.com/wailsapp/task/v3/taskfile/ast"
)
Expand Down Expand Up @@ -123,9 +124,13 @@ func RunTask(options *RunTaskOptions, otherArgs []string) error {
return nil
}

if e.Taskfile != nil && e.Taskfile.Vars == nil {
e.Taskfile.Vars = &ast.Vars{}
}

// Parse task name and CLI variables from otherArgs or os.Args
var tasksAndVars []string

// Check if we have a task name specified in options
if options.Name != "" {
// If task name is provided via options, use it and treat otherArgs as CLI variables
Expand Down Expand Up @@ -159,13 +164,13 @@ func RunTask(options *RunTaskOptions, otherArgs []string) error {
// Parse task name and CLI variables
taskName := tasksAndVars[0]
cliVars := tasksAndVars[1:]

// Create call with CLI variables
call := &ast.Call{
Task: taskName,
Vars: &ast.Vars{},
}

// Parse CLI variables (format: KEY=VALUE)
for _, v := range cliVars {
if strings.Contains(v, "=") {
Expand All @@ -174,6 +179,11 @@ func RunTask(options *RunTaskOptions, otherArgs []string) error {
call.Vars.Set(parts[0], ast.Var{
Value: parts[1],
})
if e.Taskfile != nil {
e.Taskfile.Vars.Set(parts[0], ast.Var{
Value: parts[1],
})
}
}
}
}
Expand Down
Loading