Revert behavior using DISPLAY to open app window · coder/sshcode@60b72fe

This repository was archived by the owner on Jan 17, 2021. It is now read-only.

File tree

2 files changed

lines changed

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -24,6 +24,7 @@ const codeServerPath = "~/.cache/sshcode/sshcode-server"

2424

type options struct {

2525

skipSync bool

2626

syncBack bool

27+

noOpen bool

2728

localPort string

2829

remotePort string

2930

sshFlags string

@@ -130,7 +131,7 @@ func sshCode(host, dir string, o options) error {

130131
131132

ctx, cancel = context.WithCancel(context.Background())

132133
133-

if os.Getenv("DISPLAY") != "" {

134+

if !o.noOpen {

134135

openBrowser(url)

135136

}

136137
Original file line numberDiff line numberDiff line change

@@ -6,7 +6,6 @@ import (

66

"io"

77

"net"

88

"net/http"

9-

"os"

109

"os/exec"

1110

"path/filepath"

1211

"strconv"

@@ -20,10 +19,6 @@ import (

2019

)

2120
2221

func TestSSHCode(t *testing.T) {

23-

// Avoid opening a browser window.

24-

err := os.Unsetenv("DISPLAY")

25-

require.NoError(t, err)

26-
2722

sshPort, err := randomPort()

2823

require.NoError(t, err)

2924

@@ -44,6 +39,7 @@ func TestSSHCode(t *testing.T) {

4439

sshFlags: testSSHArgs(sshPort),

4540

localPort: localPort,

4641

remotePort: remotePort,

42+

noOpen: true,

4743

})

4844

require.NoError(t, err)

4945

}()