Skip to content

Commit

Permalink
added error handling for copying local projects
Browse files Browse the repository at this point in the history
  • Loading branch information
akrami committed Jul 10, 2024
1 parent e8b7d21 commit 10db0a8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions internal/docker/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ func (project *Project) Start() error {
os.MkdirAll(getAbsoluteProjectPath(*project), os.ModePerm)
if project.Local != "" {
var srcDir string
if strings.HasPrefix(project.Local, "/") {
srcDir = project.Local
} else {
root, _ := os.Getwd()
srcDir = root + "/" + project.Local
if !strings.HasPrefix(project.Local, "/") {
srcDir = "./" + project.Local
}
err := copyutil.CopyDir(filesys.MakeFsOnDisk(), srcDir, getRelativeProjectPath(*project))
if err != nil {
return errors.Join(errors.New("cannot copy directory "+srcDir+" to "+getRelativeProjectPath(*project)), err)
}
copyutil.CopyDir(filesys.MakeFsOnDisk(), srcDir, getAbsoluteProjectPath(*project))
} else {
gitArgs := []string{"clone", project.Repository, getAbsoluteProjectPath(*project)}
if project.Branch != "" {
Expand Down Expand Up @@ -160,3 +160,7 @@ func getAbsoluteProjectPath(project Project) string {
root, _ := os.Getwd()
return root + "/workspace/" + project.Name
}

func getRelativeProjectPath(project Project) string {
return "./workspace/" + project.Name
}

0 comments on commit 10db0a8

Please sign in to comment.