Skip to content

Commit b542a65

Browse files
committed
feat(postinstall): add file integrity verification after copy
Signed-off-by: leocavalcante <[email protected]>
1 parent 236f2ec commit b542a65

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

postinstall.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* This allows OpenCode to discover and use the agents.
88
*/
99

10-
import { copyFileSync, existsSync, mkdirSync, readdirSync } from "node:fs"
10+
import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs"
1111
import { join } from "node:path"
1212

1313
import {
@@ -71,6 +71,17 @@ function main() {
7171

7272
try {
7373
copyFileSync(sourcePath, targetPath)
74+
75+
// Verify the copy succeeded by comparing file sizes
76+
const sourceSize = statSync(sourcePath).size
77+
const targetSize = statSync(targetPath).size
78+
79+
if (sourceSize !== targetSize) {
80+
throw new Error(
81+
`File size mismatch: source=${sourceSize} bytes, target=${targetSize} bytes`,
82+
)
83+
}
84+
7485
successes.push(file)
7586
console.log(` Installed: ${file}`)
7687
} catch (err) {

0 commit comments

Comments
 (0)