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

Add bun support #26

Closed
Closed
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
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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 @@ -50,6 +51,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 Down Expand Up @@ -167,12 +170,18 @@ function updateYarnLockfile(lock, latest) {
return { content, versions }
}

function updateBunLockfile(lock, latest) {
throw new Error("To be implemented")
}

function updateLockfile(lock, latest) {
if (!lock.content) lock.content = readFileSync(lock.file).toString()

let updatedLockFile
if (lock.mode === 'yarn') {
updatedLockFile = updateYarnLockfile(lock, latest)
} else if (lock.mode === 'bun') {
updatedLockFile = updateBunLockfile(lock, latest)
} else {
updatedLockFile = updateNpmLockfile(lock, latest)
}
Expand Down