mirror of
https://github.com/go-task/task.git
synced 2025-04-23 12:18:57 +02:00
fix(remote): wait for prompt in the reader (#1833)
This commit is contained in:
parent
38d0fc2c55
commit
30c59bf387
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/dominikbraun/graph"
|
"github.com/dominikbraun/graph"
|
||||||
@ -38,6 +39,7 @@ type Reader struct {
|
|||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
tempDir string
|
tempDir string
|
||||||
logger *logger.Logger
|
logger *logger.Logger
|
||||||
|
promptMutex sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewReader(
|
func NewReader(
|
||||||
@ -58,6 +60,7 @@ func NewReader(
|
|||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
tempDir: tempDir,
|
tempDir: tempDir,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
|
promptMutex: sync.Mutex{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,12 +247,16 @@ func (r *Reader) readNode(node Node) (*ast.Taskfile, error) {
|
|||||||
// If there is a cached hash, but it doesn't match the expected hash, prompt the user to continue
|
// If there is a cached hash, but it doesn't match the expected hash, prompt the user to continue
|
||||||
prompt = fmt.Sprintf(taskfileChangedPrompt, node.Location())
|
prompt = fmt.Sprintf(taskfileChangedPrompt, node.Location())
|
||||||
}
|
}
|
||||||
|
|
||||||
if prompt != "" {
|
if prompt != "" {
|
||||||
if err := r.logger.Prompt(logger.Yellow, prompt, "n", "y", "yes"); err != nil {
|
if err := func() error {
|
||||||
|
r.promptMutex.Lock()
|
||||||
|
defer r.promptMutex.Unlock()
|
||||||
|
return r.logger.Prompt(logger.Yellow, prompt, "n", "y", "yes")
|
||||||
|
}(); err != nil {
|
||||||
return nil, &errors.TaskfileNotTrustedError{URI: node.Location()}
|
return nil, &errors.TaskfileNotTrustedError{URI: node.Location()}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the hash has changed (or is new)
|
// If the hash has changed (or is new)
|
||||||
if checksum != cachedChecksum {
|
if checksum != cachedChecksum {
|
||||||
// Store the checksum
|
// Store the checksum
|
||||||
|
Loading…
x
Reference in New Issue
Block a user