Skip to content

Commit

Permalink
Merge pull request #195 from zeabur/yuanlin/zea-2453-use-bun-as-pkg-m…
Browse files Browse the repository at this point in the history
…anager-in-nodejs-provider

fix: Use bun as pkg manager for Node.js provider
  • Loading branch information
Yuanlin Lin authored Jan 19, 2024
2 parents 35fb5d6 + cb12367 commit 27e5362
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions internal/bun/identify.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ func (i *identify) Match(fs afero.Fs) bool {
hasBunTypes = bytes.Contains(packageJSON, []byte(`"bun-types"`))
}

// Some developer use bun as package manager for their Next.js or Nuxt.js project.
// In this case, we should treat it as a Node.js project.
if bytes.Contains(packageJSON, []byte(`"next"`)) || bytes.Contains(packageJSON, []byte(`"nuxt"`)) {
return false
}

return hasPackageJSON && (hasBunLockfile || hasBunTypes)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/nodejs/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func getContextBasedOnMeta(meta types.PlanMeta) TemplateContext {
OutputDir: meta["outputDir"],

// The flag specific to planner/bun.
Bun: meta["bun"] == "true",
Bun: meta["bun"] == "true" || meta["packageManager"] == "bun",
}

return context
Expand Down
5 changes: 5 additions & 0 deletions internal/nodejs/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func DeterminePackageManager(ctx *nodePlanContext) types.NodePackageManager {
return pm.Unwrap()
}

if utils.HasFile(src, "bun.lockb") {
*pm = optional.Some(types.NodePackageManagerBun)
return pm.Unwrap()
}

*pm = optional.Some(types.NodePackageManagerUnknown)
return pm.Unwrap()
}
Expand Down

0 comments on commit 27e5362

Please sign in to comment.