Skip to content

Commit a73476d

Browse files
committed
Get tests passing using pipePty implementation
1 parent c949d44 commit a73476d

File tree

7 files changed

+241
-207
lines changed

7 files changed

+241
-207
lines changed

cli/login.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ func login() *cobra.Command {
4444
return xerrors.Errorf("has initial user: %w", err)
4545
}
4646
if !hasInitialUser {
47-
if !isTTY(cmd.InOrStdin()) {
48-
return xerrors.New("the initial user cannot be created in non-interactive mode. use the API")
49-
}
47+
// TODO: Bryan - is this check correct on windows?
48+
// if !isTTY(cmd.InOrStdin()) {
49+
// return xerrors.New("the initial user cannot be created in non-interactive mode. use the API")
50+
// }
5051
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s Your Coder deployment hasn't been set up!\n", color.HiBlackString(">"))
5152

5253
_, err := runPrompt(cmd, &promptui.Prompt{

expect/conpty/conpty.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package conpty
88

99
import (
1010
"fmt"
11+
"io"
1112
"os"
1213

1314
"golang.org/x/sys/windows"
@@ -42,14 +43,22 @@ func (c *ConPty) Close() error {
4243

4344
// OutPipe returns the output pipe of the pseudo terminal
4445
func (c *ConPty) OutPipe() *os.File {
46+
return c.inPipe
47+
}
48+
49+
func (c *ConPty) Reader() io.Reader {
4550
return c.outPipe
4651
}
4752

4853
// InPipe returns input pipe of the pseudo terminal
4954
// Note: It is safer to use the Write method to prevent partially-written VT sequences
5055
// from corrupting the terminal
5156
func (c *ConPty) InPipe() *os.File {
52-
return c.inPipe
57+
return c.outPipe
58+
}
59+
60+
func (c *ConPty) WriteString(str string) (int, error) {
61+
return c.inPipe.WriteString(str)
5362
}
5463

5564
func (c *ConPty) createPseudoConsoleAndPipes() error {

expect/console.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ func (c *Console) Send(s string) (int, error) {
217217

218218
// SendLine writes string s to Console's tty with a trailing newline.
219219
func (c *Console) SendLine(s string) (int, error) {
220-
return c.Send(fmt.Sprintf("%s\n", s))
220+
bytes, err := c.Send(fmt.Sprintf("%s\r\n", s))
221+
222+
return bytes, err
221223
}
222224

223225
// Log prints to Console's logger.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy