From 6ece4b768cdde3c0379b73e4bc1ccd15f96b8dfd Mon Sep 17 00:00:00 2001 From: psihachina Date: Mon, 10 Oct 2022 13:41:28 +0300 Subject: [PATCH] fixed check tty (build for windows) --- internal/commands/initialize.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/internal/commands/initialize.go b/internal/commands/initialize.go index aea90677..9a57b8c0 100644 --- a/internal/commands/initialize.go +++ b/internal/commands/initialize.go @@ -5,7 +5,7 @@ import ( "github.com/AlecAivazis/survey/v2" "github.com/hazelops/ize/internal/schema" "github.com/hazelops/ize/internal/version" - "golang.org/x/sys/unix" + "golang.org/x/term" "os" "path/filepath" "sort" @@ -103,11 +103,7 @@ func (o *InitOptions) Validate() error { } func (o *InitOptions) Run() error { - isTTY := true - _, err := unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ) - if err != nil { - isTTY = false - } + isTTY := term.IsTerminal(int(os.Stdout.Fd())) if len(o.Template) != 0 { dest, err := generate.GenerateFiles(o.Template, o.Output) if err != nil { @@ -135,7 +131,7 @@ func (o *InitOptions) Run() error { } } - dir, err = filepath.Abs(o.Output) + dir, err := filepath.Abs(o.Output) if err != nil { return fmt.Errorf("can't init: %w", err) }