fix: close input on shutdown whenever possible

This commit is contained in:
Christian Muehlhaeuser 2022-10-07 23:29:01 +02:00
parent 6477a53545
commit fbb00cc71e
1 changed files with 4 additions and 6 deletions

10
tea.go
View File

@ -351,9 +351,6 @@ func (p *Program) StartReturningModel() (Model, error) {
if err != nil {
return p.initialModel, err
}
defer f.Close() //nolint:errcheck
p.input = f
case !p.startupOptions.has(withCustomInput):
@ -373,12 +370,13 @@ func (p *Program) StartReturningModel() (Model, error) {
if err != nil {
return p.initialModel, err
}
defer f.Close() //nolint:errcheck
p.input = f
}
if f, ok := p.input.(io.ReadCloser); ok {
defer f.Close() //nolint:errcheck
}
// Handle signals.
if !p.startupOptions.has(withoutSignalHandler) {
handlers.add(p.handleSignals())