Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

MrChrisRodriguez
Copy link

Modern bun uses .lock instead of .lockb files. This updates detect-package-manager to detect both.

Copy link

changeset-bot bot commented Jul 8, 2025

⚠️ No Changeset found

Latest commit: 5966e48

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
Member

@theoephraim theoephraim left a comment

Choose a reason for hiding this comment

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

This is great :) Massaged a bit to show the detected file names rather than a list of possible ones.

I didn't test it yet though, so could have made a mistake. If it looks good to you, commit the suggestions and I'll do another test before merging.

Comment on lines +70 to +72
const lockfiles = Array.isArray(JS_PACKAGE_MANAGERS[pm].lockfile)
? JS_PACKAGE_MANAGERS[pm].lockfile
: [JS_PACKAGE_MANAGERS[pm].lockfile as string];
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const lockfiles = Array.isArray(JS_PACKAGE_MANAGERS[pm].lockfile)
? JS_PACKAGE_MANAGERS[pm].lockfile
: [JS_PACKAGE_MANAGERS[pm].lockfile as string];
const possibleLockFiles = _.castArray(JS_PACKAGE_MANAGERS[pm].lockfile));

Comment on lines +74 to +81
let lockFileExists = false;
for (const lockfile of lockfiles) {
const lockFilePath = path.join(cwd, lockfile);
if (pathExistsSync(lockFilePath)) {
lockFileExists = true;
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let lockFileExists = false;
for (const lockfile of lockfiles) {
const lockFilePath = path.join(cwd, lockfile);
if (pathExistsSync(lockFilePath)) {
lockFileExists = true;
break;
}
}
const thisPmLockFile = _.find(possibleLockFiles, (lockFileName) => pathExistsSync(path.join(cwd, lockFileName)));

}
}

if (lockFileExists) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (lockFileExists) {
if (thisPmlockFile) {

const cwdParts = cwd.split('/');
do {
let pm: JsPackageManager;
let detectedPm: JsPackageManager | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let detectedPm: JsPackageManager | undefined;
let detectedPm: JsPackageManager | undefined;
let detectedPmLockFile: string | undefined;

Comment on lines +85 to 94
if (detectedPm) {
const currentLockfiles = Array.isArray(JS_PACKAGE_MANAGERS[pm].lockfile)
? (JS_PACKAGE_MANAGERS[pm].lockfile as string[]).join(' or ')
: JS_PACKAGE_MANAGERS[pm].lockfile;
const detectedLockfiles = Array.isArray(JS_PACKAGE_MANAGERS[detectedPm].lockfile)
? (JS_PACKAGE_MANAGERS[detectedPm].lockfile as string[]).join(' or ')
: JS_PACKAGE_MANAGERS[detectedPm].lockfile;
throw new Error(`Found multiple js package manager lockfiles - ${currentLockfiles} and ${detectedLockfiles}`);
}
detectedPm = pm;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (detectedPm) {
const currentLockfiles = Array.isArray(JS_PACKAGE_MANAGERS[pm].lockfile)
? (JS_PACKAGE_MANAGERS[pm].lockfile as string[]).join(' or ')
: JS_PACKAGE_MANAGERS[pm].lockfile;
const detectedLockfiles = Array.isArray(JS_PACKAGE_MANAGERS[detectedPm].lockfile)
? (JS_PACKAGE_MANAGERS[detectedPm].lockfile as string[]).join(' or ')
: JS_PACKAGE_MANAGERS[detectedPm].lockfile;
throw new Error(`Found multiple js package manager lockfiles - ${currentLockfiles} and ${detectedLockfiles}`);
}
detectedPm = pm;
if (detectedPmLockFile) {
throw new Error(`Found multiple js package manager lockfiles - ${thisPmLockFile} and ${detectedPmLockFile}`);
}
detectedPmLockFile = thisPmLockFile;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants