-
-
Notifications
You must be signed in to change notification settings - Fork 8
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!: improve detect algorithm, detect
runs null
when dismatch, fix #9
#10
Conversation
detect
runs null
when dismatch, fix #9
const lockPath = await findUp(Object.keys(LOCKS), { cwd }) | ||
let packageJsonPath: string | undefined | ||
export interface DetectResult { | ||
agent: Agent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit unrelated to the issue being solved here, but I though I'd mention that the other thing that might be helpful here is to return the package manager. most usages I've seen are just looking for that and so always end up having to do agent.split('@')[0]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do another PR to separate that fields
for (const directory of lookup(cwd)) { | ||
// Look up for lock files | ||
for (const lock of Object.keys(LOCKS)) { | ||
if (await fileExists(path.join(directory, lock))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this would solve the reported issue. I understood the issue to be something like:
rootproj
|-package.json
|-pnpm.lock
|-packages
|- subproj
|- package.json (contains packageManager field)
So I think we'd need to check for the presence of the packageManager
field independently of checking for the lockfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's the new behaviour. Instead of findUp
separately for locks and packageManager field, now we check both in each directory up (the lookup
function) and get the closest match
Change to scan the lock and package.json at the same time and return the first match. Ideally it would be sightly more efficient as the lookup will only happen once now