|
|
@@ -1,32 +0,0 @@
|
|
|
-import semver from "semver"
|
|
|
-import { text } from "node:stream/consumers"
|
|
|
-import { Log } from "../util/log"
|
|
|
-import { Process } from "../util/process"
|
|
|
-
|
|
|
-export namespace PackageRegistry {
|
|
|
- const log = Log.create({ service: "bun" })
|
|
|
-
|
|
|
- function which() {
|
|
|
- return process.execPath
|
|
|
- }
|
|
|
-
|
|
|
- export async function info(pkg: string, field: string, cwd?: string): Promise<string | null> {
|
|
|
- const { code, stdout, stderr } = await Process.run([which(), "info", pkg, field], {
|
|
|
- cwd,
|
|
|
- env: {
|
|
|
- ...process.env,
|
|
|
- BUN_BE_BUN: "1",
|
|
|
- },
|
|
|
- nothrow: true,
|
|
|
- })
|
|
|
-
|
|
|
- if (code !== 0) {
|
|
|
- log.warn("bun info failed", { pkg, field, code, stderr: stderr.toString() })
|
|
|
- return null
|
|
|
- }
|
|
|
-
|
|
|
- const value = stdout.toString().trim()
|
|
|
- if (!value) return null
|
|
|
- return value
|
|
|
- }
|
|
|
-}
|