Skip to content

Commit afc7a10

Browse files
anandgupta42claude
andcommitted
fix: address code review — idempotency guard and test assertion accuracy
- Add `if (!pkg.name || !pkg.version) continue` guard in publish.ts glob loop to prevent crash on re-run when synthesized package.json (lacking name/version) is picked up - Fix test assertion to match JS object literal `type: "module"` instead of the comment containing `"type": "module"` Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 043c7a9 commit afc7a10

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎packages/opencode/script/publish.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const driverPeerDependenciesMeta: Record<string, { optional: true }> = Object.fr
3838
const binaries: Record<string, string> = {}
3939
for (const filepath of new Bun.Glob("**/package.json").scanSync({ cwd: "./dist" })) {
4040
const pkg = await Bun.file(`./dist/${filepath}`).json()
41+
// Skip synthesized package.json files (e.g. dbt-tools) that lack name/version
42+
if (!pkg.name || !pkg.version) continue
4143
binaries[pkg.name] = pkg.version
4244
}
4345
console.log("binaries", binaries)

‎packages/opencode/test/install/dbt-tools-bundle.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ describe("publish.ts dbt-tools ESM bundling", () => {
4747
})
4848

4949
test('bundled package.json includes "type": "module"', () => {
50-
// The publish script must write `{ "type": "module" }` (or equivalent)
50+
// The publish script must write `{ type: "module" }` (or equivalent)
5151
// so that Node treats .js files in dbt-tools/ as ESM.
52-
expect(publishSource).toContain('"type": "module"')
52+
// Match the JS object literal (unquoted key), not just the comment.
53+
expect(publishSource).toContain('type: "module"')
5354
})
5455

5556
test("copyAssets creates dbt-tools/bin and dbt-tools/dist directories", () => {

0 commit comments

Comments
 (0)