Skip to content

Commit 9149dd8

Browse files
fbrbovicclaude
andcommitted
fix(build): fix glob pattern expansion in build script
Fix tarball extraction by using JavaScript fs.readdirSync() to find actual filenames instead of relying on shell glob expansion which doesn't work in Bun's $ command. This allows the build script to successfully compile OpenCode binaries. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 18ad7a3 commit 9149dd8

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/opencode/script/build.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,24 @@ for (const [os, arch] of targets) {
4242
const opentui = `@opentui/core-${os === "windows" ? "win32" : os}-${arch.replace("-baseline", "")}`
4343
await $`mkdir -p ../../node_modules/${opentui}`
4444
await $`npm pack ${opentui}@${pkg.dependencies["@opentui/core"]}`.cwd(path.join(dir, "../../node_modules"))
45-
await $`tar -xf ../../node_modules/${opentui.replace("@opentui/", "opentui-")}-*.tgz -C ../../node_modules/${opentui} --strip-components=1`
45+
46+
// Find the actual tarball file created by npm pack
47+
const opentuiTarballPattern = `${opentui.replace("@opentui/", "opentui-")}-*.tgz`
48+
const opentuiFiles = fs.readdirSync(path.join(dir, "../../node_modules"))
49+
const opentuiTarball = opentuiFiles.find(f => f.startsWith(opentui.replace("@opentui/", "opentui-")) && f.endsWith(".tgz"))
50+
if (!opentuiTarball) throw new Error(`Could not find opentui tarball matching ${opentuiTarballPattern}`)
51+
await $`tar -xf ../../node_modules/${opentuiTarball} -C ../../node_modules/${opentui} --strip-components=1`
4652

4753
const watcher = `@parcel/watcher-${os === "windows" ? "win32" : os}-${arch.replace("-baseline", "")}${os === "linux" ? "-glibc" : ""}`
4854
await $`mkdir -p ../../node_modules/${watcher}`
4955
await $`npm pack ${watcher}`.cwd(path.join(dir, "../../node_modules")).quiet()
50-
await $`tar -xf ../../node_modules/${watcher.replace("@parcel/", "parcel-")}-*.tgz -C ../../node_modules/${watcher} --strip-components=1`
56+
57+
// Find the actual tarball file created by npm pack
58+
const watcherTarballPattern = `${watcher.replace("@parcel/", "parcel-")}-*.tgz`
59+
const watcherFiles = fs.readdirSync(path.join(dir, "../../node_modules"))
60+
const watcherTarball = watcherFiles.find(f => f.startsWith(watcher.replace("@parcel/", "parcel-")) && f.endsWith(".tgz"))
61+
if (!watcherTarball) throw new Error(`Could not find watcher tarball matching ${watcherTarballPattern}`)
62+
await $`tar -xf ../../node_modules/${watcherTarball} -C ../../node_modules/${watcher} --strip-components=1`
5163

5264
const parserWorker = fs.realpathSync(path.resolve(dir, "./node_modules/@opentui/core/parser.worker.js"))
5365
const workerPath = "./src/cli/cmd/tui/worker.ts"

0 commit comments

Comments
 (0)