Skip to content

Commit ca33fa2

Browse files
committed
feat: support "~" (home) at the start of sync path
1 parent 602c322 commit ca33fa2

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

pkg/devspace/context/context.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ package context
22

33
import (
44
context2 "context"
5+
"os"
6+
"path"
7+
"path/filepath"
8+
"runtime"
9+
"strings"
10+
511
"github.com/loft-sh/devspace/pkg/devspace/config"
612
"github.com/loft-sh/devspace/pkg/devspace/dependency/types"
713
"github.com/loft-sh/devspace/pkg/devspace/kubectl"
@@ -11,11 +17,6 @@ import (
1117
"github.com/loft-sh/devspace/pkg/util/tomb"
1218
"github.com/pkg/errors"
1319
"mvdan.cc/sh/v3/expand"
14-
"os"
15-
"path"
16-
"path/filepath"
17-
"runtime"
18-
"strings"
1920
)
2021

2122
func NewContext(ctx context2.Context, variables map[string]interface{}, log log.Logger) Context {
@@ -198,6 +199,15 @@ func (c *context) ResolvePath(relPath string) string {
198199
return path.Clean(relPath)
199200
}
200201

202+
homeDir, err := os.UserHomeDir()
203+
if err == nil {
204+
if relPath == "~" {
205+
return homeDir
206+
} else if strings.HasPrefix(relPath, "~/") {
207+
return path.Clean(filepath.Join(homeDir, relPath[2:]))
208+
}
209+
}
210+
201211
outPath := path.Join(filepath.ToSlash(c.workingDir), relPath)
202212
if !filepath.IsAbs(outPath) {
203213
return c.workingDir

0 commit comments

Comments
 (0)