mirror of
https://github.com/docker/compose.git
synced 2026-08-03 22:27:30 +00:00
detect terminal is not a console.File to avoid a panic
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
dc01b98aa6
commit
18a112e88c
2 changed files with 10 additions and 4 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/cloudflare/cfssl/log"
|
||||
"github.com/docker/compose/v2/pkg/api"
|
||||
|
||||
"github.com/containerd/console"
|
||||
|
|
@ -118,11 +119,16 @@ func NewWriter(ctx context.Context, out io.Writer, progressTitle string) (Writer
|
|||
if !ok {
|
||||
dryRun = false
|
||||
}
|
||||
if Mode == ModeAuto && isTerminal {
|
||||
return newTTYWriter(out.(console.File), dryRun, progressTitle)
|
||||
f, isConsole := out.(console.File) // see https://github.com/docker/compose/issues/10560
|
||||
if Mode == ModeAuto && isTerminal && isConsole {
|
||||
return newTTYWriter(f, dryRun, progressTitle)
|
||||
}
|
||||
if Mode == ModeTTY {
|
||||
return newTTYWriter(out.(console.File), dryRun, progressTitle)
|
||||
if !isConsole {
|
||||
log.Warning("Terminal is not a POSIX console")
|
||||
} else {
|
||||
return newTTYWriter(f, dryRun, progressTitle)
|
||||
}
|
||||
}
|
||||
return &plainWriter{
|
||||
out: out,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue