Skip to content

detectPackageManager thinks yarn package is being used due to findWorkspaceRoot() #4

Closed
@caschbre

Description

@caschbre

First of all, thanks for adding the pnpm workspace support so quickly! I've been beating my head trying to patch packages in pnpm workspaces for quite a while now.

I did come across a minor issue with the package detection logic. The following code is causing the pnpm workspace detection to never get executed.

  } else if (yarnLockExists || findWorkspaceRoot()) {
    return "yarn"
  } else if (isFileInPnpmRoot(appRootPath, "pnpm-lock.yaml")) {
    // (fs.existsSync(join(appRootPath, "pnpm-lock.yaml"))) {
    return "pnpm"

What is interesting is I do not even have yarn installed on my machine. It looks like findWorkspaceRoot() (from the find-yarn-workspace-root package) doesn't test if you have yarn, it just returns what it thinks is the workspace root. So that always seems to return a string if you're using workspaces, regardless of yarn being used or even installed.

I'm not sure if that needs to be changed to yarnLockExists && findWorkspaceRoot() or just swap the order of the else if blocks so that it has a chance to detect pnpm first.

I simply commented out the logic block that uses findWorkspaceRoot() and the pnpm workspace was detected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions