Skip to content
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ ecc2/target/
# Generated lock files in tool subdirectories
.opencode/package-lock.json
.opencode/node_modules/

# yarn is the canonical package manager for this repo (see package.json
# "packageManager"); ignore stray lockfiles from running another manager locally
/bun.lock
/bun.lockb
assets/images/security/badrudi-exploit.mp4

.aider*
9 changes: 6 additions & 3 deletions scripts/lib/package-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ const PACKAGE_MANAGERS = {
},
bun: {
name: 'bun',
lockFile: 'bun.lockb',
lockFile: 'bun.lock',
// Bun switched its default lockfile from the binary bun.lockb to the
// text-based bun.lock. Keep recognizing the legacy file too.
lockFileAliases: ['bun.lockb'],
installCmd: 'bun install',
runCmd: 'bun run',
execCmd: 'bunx',
Expand Down Expand Up @@ -92,9 +95,9 @@ function saveConfig(config) {
function detectFromLockFile(projectDir = process.cwd()) {
for (const pmName of DETECTION_PRIORITY) {
const pm = PACKAGE_MANAGERS[pmName];
const lockFilePath = path.join(projectDir, pm.lockFile);
const lockFileNames = [pm.lockFile, ...(pm.lockFileAliases || [])];

if (fs.existsSync(lockFilePath)) {
if (lockFileNames.some(lockFileName => fs.existsSync(path.join(projectDir, lockFileName)))) {
return pmName;
}
}
Expand Down
14 changes: 13 additions & 1 deletion tests/lib/package-manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function runTests() {
})) passed++;
else failed++;

if (test('detects bun from bun.lockb', () => {
if (test('detects bun from bun.lockb (legacy binary lockfile)', () => {
const testDir = createTestDir();
try {
fs.writeFileSync(path.join(testDir, 'bun.lockb'), '');
Expand All @@ -143,6 +143,18 @@ function runTests() {
})) passed++;
else failed++;

if (test('detects bun from bun.lock (modern text lockfile)', () => {
const testDir = createTestDir();
try {
fs.writeFileSync(path.join(testDir, 'bun.lock'), '');
const result = pm.detectFromLockFile(testDir);
assert.strictEqual(result, 'bun');
} finally {
cleanupTestDir(testDir);
}
})) passed++;
else failed++;

if (test('returns null when no lock file exists', () => {
const testDir = createTestDir();
try {
Expand Down