mirror of
https://github.com/docker/compose.git
synced 2026-02-09 01:59:22 +08: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:
committed by
Nicolas De loof
parent
dc01b98aa6
commit
18a112e88c
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user