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

Bun support for update-browserslist-db #40

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function detectLockfile() {
let lockfileShrinkwrap = join(packageDir, 'npm-shrinkwrap.json')
let lockfileYarn = join(packageDir, 'yarn.lock')
let lockfilePnpm = join(packageDir, 'pnpm-lock.yaml')
let lockfileBun = join(packageDir, 'bun.lockb')

if (existsSync(lockfilePnpm)) {
return { file: lockfilePnpm, mode: 'pnpm' }
Expand All @@ -54,6 +55,8 @@ function detectLockfile() {
return lock
} else if (existsSync(lockfileShrinkwrap)) {
return { file: lockfileShrinkwrap, mode: 'npm' }
} else if (existsSync(lockfileBun)) {
return { file: lockfileBun, mode: 'bun' }
}
throw new BrowserslistUpdateError(
'No lockfile found. Run "npm install", "yarn install" or "pnpm install"'
Expand All @@ -75,6 +78,13 @@ function getLatestInfo(lock) {
if (lock.mode === 'pnpm') {
return JSON.parse(execSync('pnpm info caniuse-lite --json').toString())
}
if (lock.mode === 'bun') {
// TO-DO: No 'bun info' yet. Created issue: https://github.com/oven-sh/bun/issues/12280
return JSON.parse(
execSync(' npm info caniuse-lite --json').toString()
pornoiya marked this conversation as resolved.
Show resolved Hide resolved
)
}

return JSON.parse(execSync('npm show caniuse-lite --json').toString())
}

Expand Down Expand Up @@ -287,6 +297,8 @@ module.exports = function updateDB(print = defaultPrint) {
updateWith(print, yarnCommand + ' up -R caniuse-lite')
} else if (lock.mode === 'pnpm') {
updateWith(print, 'pnpm up caniuse-lite')
} else if (lock.mode === 'bun') {
updateWith(print, 'bun update caniuse-lite')
} else {
updatePackageManually(print, lock, latest)
}
Expand Down
Loading
Loading