Skip to content
This repository was archived by the owner on Feb 2, 2026. It is now read-only.

Commit e8315d9

Browse files
committed
Update postinstall.mjs
1 parent 5fc9dab commit e8315d9

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

scripts/postinstall.mjs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,53 @@ async function copyIfExists(src, dst) {
2727
}
2828

2929
async function run() {
30+
console.log(`[${pkg.name}] postinstall started`);
31+
const startTime = Date.now();
32+
3033
if (process.env.MESSAGIX_SKIP_POSTINSTALL === "true") {
3134
console.log(`[${pkg.name}] Skipping postinstall (MESSAGIX_SKIP_POSTINSTALL=true)`);
3235
return;
3336
}
3437

38+
console.log(`[${pkg.name}] Detecting platform...`);
3539
const { triplet, ext } = detectPlatform();
40+
console.log(`[${pkg.name}] Platform: ${triplet}, ext: ${ext}`);
41+
3642
const buildOut = join(__dirname, "..", "build", `messagix.${ext}`);
43+
console.log(`[${pkg.name}] Build output path: ${buildOut}`);
3744

3845
// 1) Prefer local prebuilt shipped in npm tarball
3946
const prebuiltDir = join(__dirname, "..", "prebuilt", triplet);
4047
const prebuilt = join(prebuiltDir, `messagix.${ext}`);
48+
console.log(`[${pkg.name}] Checking local prebuilt at: ${prebuilt}`);
4149
if (await copyIfExists(prebuilt, buildOut)) {
4250
console.log(`[${pkg.name}] Using local prebuilt for ${triplet}`);
4351
if (process.env.MESSAGIX_KEEP_PREBUILT !== "true") {
4452
try {
4553
await rm(prebuiltDir, { recursive: true, force: true });
46-
} catch (error) {
47-
console.error(error);
54+
} catch {
55+
//
4856
}
4957
}
58+
console.log(`[${pkg.name}] postinstall completed in ${Date.now() - startTime}ms`);
5059
return;
5160
}
5261
console.log(`[${pkg.name}] No local prebuilt found`);
5362

5463
// 2) Try remote prebuilt from GitHub Releases
64+
console.log(`[${pkg.name}] Attempting to download remote prebuilt...`);
65+
const downloadStart = Date.now();
5566
try {
56-
if (await downloadPrebuilt()) return;
57-
} catch (error) {
58-
console.error(error);
67+
if (await downloadPrebuilt()) {
68+
console.log(`[${pkg.name}] Download completed in ${Date.now() - downloadStart}ms`);
69+
console.log(`[${pkg.name}] postinstall completed in ${Date.now() - startTime}ms`);
70+
return;
71+
}
72+
} catch (err) {
73+
console.log(
74+
`[${pkg.name}] Download failed after ${Date.now() - downloadStart}ms:`,
75+
err?.message || String(err),
76+
);
5977
}
6078

6179
// 3) No prebuilt available. Try local build if allowed
@@ -83,6 +101,9 @@ async function run() {
83101
);
84102
}
85103

86-
run().catch(err => {
87-
console.error(`[${pkg.name}] postinstall failed:`, err?.message || String(err));
88-
});
104+
run()
105+
.then(() => process.exit(0))
106+
.catch(err => {
107+
console.error(`[${pkg.name}] postinstall failed:`, err?.message || String(err));
108+
process.exit(1);
109+
});

0 commit comments

Comments
 (0)