Skip to content

Commit

Permalink
fix: return error if more than one detected runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Pehesi97 committed Oct 13, 2023
1 parent 4533069 commit 452de68
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/services/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,24 @@ func New(name string, language string, directory string, runtimeVersion string,
}

func (proj *Project) detectType() (ProjectType, error) {
detectedRuntimes := 0
var projectType ProjectType
var err error
if _, err := os.Stat(path.Join(proj.Directory, "package.json")); err == nil {
proj.DefaultRuntimeVersion = defaults.DefaultNodeRuntimeVersion
return NodeProject, nil
detectedRuntimes++
projectType = NodeProject
} else if _, err := os.Stat(path.Join(proj.Directory, "go.mod")); err == nil {
proj.DefaultRuntimeVersion = defaults.DefaultGoRuntimeVersion
return GoProject, nil
detectedRuntimes++
projectType = GoProject
} else {
return "", fmt.Errorf("cannot detect project type %v", err)
}
if detectedRuntimes > 1 {
return "", fmt.Errorf("more than one project runtime detected, use --project-language flag or the INITIUM_PROJECT_LANGUAGE env variable to set the desired runtime")
}
return projectType, err
}

func (proj *Project) matchType() (ProjectType, error) {
Expand Down

0 comments on commit 452de68

Please sign in to comment.