Skip to content
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

fix: no longer crash for single projects with global dependencies #5002

Merged
merged 4 commits into from
May 18, 2023
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
6 changes: 6 additions & 0 deletions cli/internal/packagemanager/pnpm.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package packagemanager

import (
"errors"
"fmt"
stdfs "io/fs"
"strings"

"github.com/vercel/turbo/cli/internal/fs"
Expand Down Expand Up @@ -58,6 +60,10 @@ func getPnpmWorkspaceIgnores(pm PackageManager, rootpath turbopath.AbsoluteSyste
}
pkgGlobs, err := readPnpmWorkspacePackages(rootpath.UntypedJoin("pnpm-workspace.yaml"))
if err != nil {
// If workspace file doesn't exist we shouldn't error as we might be a single package repo
if errors.Is(err, stdfs.ErrNotExist) {
return ignores, nil
}
return nil, err
}
for _, pkgGlob := range pkgGlobs {
Expand Down
4 changes: 3 additions & 1 deletion cli/internal/run/global_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ func getGlobalHashInputs(
if lockFile == nil {
// If we don't have lockfile information available, add the specfile and lockfile to global deps
globalDeps.Add(filepath.Join(rootpath.ToStringDuringMigration(), packageManager.Specfile))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially was also checking if this exists, but we'll error far earlier in turbo execution if the root package.json doesn't exist

globalDeps.Add(filepath.Join(rootpath.ToStringDuringMigration(), packageManager.Lockfile))
if rootpath.UntypedJoin(packageManager.Lockfile).Exists() {
globalDeps.Add(filepath.Join(rootpath.ToStringDuringMigration(), packageManager.Lockfile))
}
}

// No prefix, global deps already have full paths
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Setup
$ . ${TESTDIR}/../../../helpers/setup.sh
$ . ${TESTDIR}/../_helpers/setup_monorepo.sh $(pwd) single_package pnpm@8.0.0

We only care about this running sucessfully and not the json output
$ ${TURBO} run build --dry=json > /dev/null