Skip to content

Commit f68e7f8

Browse files
committed
Skip native postinstall bootstrap in CI and Vercel
1 parent 38d361a commit f68e7f8

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"install:rust-deps": "tsx scripts/install-rust-deps.ts",
4141
"build:native": "tsx scripts/build-native.ts",
4242
"build:native:copy": "tsx scripts/copy-napi.ts",
43-
"postinstall": "simple-git-hooks && pnpm run install:rust-deps && pnpm run build:native"
43+
"postinstall": "tsx scripts/postinstall.ts"
4444
},
4545
"author": {
4646
"email": "truenine304520@gmail.com",

scripts/postinstall.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env tsx
2+
import {execSync} from 'node:child_process'
3+
import process from 'node:process'
4+
5+
const CI_ENV_VARS = ['CI', 'GITHUB_ACTIONS', 'VERCEL', 'VERCEL_ENV'] as const
6+
7+
function hasTruthyEnv(name: (typeof CI_ENV_VARS)[number]): boolean {
8+
const value = process.env[name]
9+
return typeof value === 'string' && value.length > 0 && value !== '0' && value !== 'false'
10+
}
11+
12+
if (CI_ENV_VARS.some(hasTruthyEnv)) {
13+
console.log('[postinstall] CI or Vercel detected, skipping git hooks and native bootstrap')
14+
process.exit(0)
15+
}
16+
17+
const commands = [
18+
'simple-git-hooks',
19+
'pnpm run install:rust-deps',
20+
'pnpm run build:native',
21+
] as const
22+
23+
for (const command of commands) {
24+
execSync(command, {
25+
stdio: 'inherit',
26+
})
27+
}

0 commit comments

Comments
 (0)