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 package manager detection in non-monorepos #907

Merged
merged 1 commit into from Nov 27, 2023
Merged

Conversation

askoufis
Copy link
Contributor

@askoufis askoufis commented Nov 26, 2023

For reasons unknown, @manypkg/find-root only returns a tool (package manager) if it detects that you're in a monorepo. If you're not, it returns a Root tool, which is absolutely useless.

This was causing yarn (via the fallback logic) to be incorrectly detected as the package manager in a pnpm repo, causing sku pre-commit to run the wrong command (yarn --check-files).

I've kept the root directory detection from @manypkg/find-root, but leveraged @antfu/ni's API for detecting the package manager in the case where a non-supported tool is detected. This involves looking for lockfiles, which is what the detect API from @antfu/ni does, but it's async only, so I've made a synchronous version because package manager detection in sku can't be made async right now.

Finally, I made the lintStaged call use config defined as an object rather than resolving to a file because it's simpler IMO. I did this initially as I thought maybe the lint staged config was the issue.

@askoufis askoufis requested a review from a team as a code owner November 26, 2023 22:53
Copy link

changeset-bot bot commented Nov 26, 2023

🦋 Changeset detected

Latest commit: 8b88a6d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sku Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@askoufis askoufis merged commit 76ccc69 into master Nov 27, 2023
5 checks passed
@askoufis askoufis deleted the fix-pre-commit branch November 27, 2023 03:07
@seek-oss-ci seek-oss-ci mentioned this pull request Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants