Skip to content

feat(cli): add coder open vscode #11191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jan 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle more abs paths
  • Loading branch information
mafredri committed Jan 2, 2024
commit 2fd24645f9c3e5fa8caeed3f810fb66d0022464d
8 changes: 7 additions & 1 deletion cli/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/url"
"path"
"path/filepath"
"strings"

Expand Down Expand Up @@ -106,8 +107,13 @@ func (r *RootCmd) openVSCode() *clibase.Cmd {
switch {
case len(inv.Args) > 1:
directory = inv.Args[1]

// We explicitly use `path.IsAbs` (vs `filepath`) because only
// Windows absolute paths may start without "/".
isUnixAndNotAbs := workspaceAgent.OperatingSystem != "windows" && !path.IsAbs(directory)

// Perhaps we could SSH in to expand the directory?
if !insideThisWorkspace && strings.HasPrefix(directory, "~") {
if !insideThisWorkspace && (strings.HasPrefix(directory, "~") || isUnixAndNotAbs) {
return xerrors.Errorf("directory path %q not supported, use an absolute path instead", directory)
}
if insideThisWorkspace {
Expand Down