这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions cli/internal/backends/nodejs/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ var NodejsYarnBackend = api.LanguageBackend{
if err != nil {
return nil, fmt.Errorf("package.json: %w", err)
}
if len(pkg.Workspaces) == 0 {
return nil, fmt.Errorf("package.json: no workspaces found. Turborepo requires Yarn workspaces to be defined in the root package.json")
}
return pkg.Workspaces, nil
},
GetPackageDir: func() string {
Expand Down Expand Up @@ -53,6 +56,11 @@ var NodejsPnpmBackend = api.LanguageBackend{
if err := yaml.Unmarshal(bytes, &pnpmWorkspaces); err != nil {
return nil, fmt.Errorf("pnpm-workspace.yaml: %w", err)
}

if len(pnpmWorkspaces.Packages) == 0 {
return nil, fmt.Errorf("pnpm-workspace.yaml: no packages found. Turborepo requires PNPM workspaces and thus packages to be defined in the root pnpm-workspace.yaml")
}

return pnpmWorkspaces.Packages, nil
},
GetPackageDir: func() string {
Expand All @@ -73,6 +81,9 @@ var NodejsNpmBackend = api.LanguageBackend{
if err != nil {
return nil, fmt.Errorf("package.json: %w", err)
}
if len(pkg.Workspaces) == 0 {
return nil, fmt.Errorf("package.json: no workspaces found. Turborepo requires NPM workspaces to be defined in the root package.json")
}
return pkg.Workspaces, nil
},
GetPackageDir: func() string {
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ func WithGraph(rootpath string, config *config.Config) Option {
c.RootPackageJSON = pkg

spaces, err := c.Backend.GetWorkspaceGlobs()

if err != nil {
return err
return fmt.Errorf("could not detect workspaces: %w", err)
}

// Calculate the global hash
Expand Down