Skip to content

Commit bb52937

Browse files
fix: skip logging during execution
fix #126
1 parent 5040c1d commit bb52937

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

.changeset/tender-dogs-enter.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ast-grep/setup-lang": patch
3+
---
4+
5+
skip logging when running

scripts/setup/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface SetupConfig {
1919
*/
2020
function postinstall(config: SetupConfig) {
2121
const dir = config.dirname
22-
const prebuild = resolvePrebuild(dir)
22+
const prebuild = resolvePrebuild(dir, true)
2323
if (prebuild) {
2424
log('prebuild found, do not need to build')
2525
return
@@ -61,7 +61,7 @@ const ARCH_MAP: Record<string, string> = {
6161
/**
6262
* Resolve prebuild path
6363
*/
64-
function resolvePrebuild(dir: string) {
64+
function resolvePrebuild(dir: string, needLog = false) {
6565
const os = PLATFORM_MAP[process.platform]
6666
const arch = ARCH_MAP[process.arch]
6767
const prebuild = path.join(
@@ -71,10 +71,14 @@ function resolvePrebuild(dir: string) {
7171
'parser.so',
7272
)
7373
if (!os || !arch || !fs.existsSync(prebuild)) {
74-
log(`no prebuild for ${os} ${arch}`)
74+
if (needLog) {
75+
log(`no prebuild for ${os} ${arch}`)
76+
}
7577
return undefined
7678
}
77-
log(`found prebuild for ${os} ${arch}`)
79+
if (needLog) {
80+
log(`found prebuild for ${os} ${arch}`)
81+
}
7882
return prebuild
7983
}
8084

0 commit comments

Comments
 (0)