Skip to content

Commit 15f74f1

Browse files
committed
Use readJsonSync
1 parent 61bec03 commit 15f74f1

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/utils/coana.mts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { readFileSync } from 'node:fs'
2-
1+
import { readJsonSync } from '@socketsecurity/registry/lib/fs'
32
import { spawn } from '@socketsecurity/registry/lib/spawn'
43

54
import { getDefaultOrgSlug } from '../commands/ci/fetch-default-org-slug.mts'
@@ -65,11 +64,9 @@ export async function spawnCoana(
6564
export function extractTier1ReachabilityScanId(
6665
socketFactsFile: string,
6766
): string | undefined {
68-
try {
69-
const content = readFileSync(socketFactsFile, 'utf8')
70-
const json = JSON.parse(content)
71-
return json.tier1ReachabilityScanId
72-
} catch {
73-
return undefined
74-
}
67+
const json = readJsonSync(socketFactsFile, { throws: false })
68+
const tier1ReachabilityScanId = json?.['tier1ReachabilityScanId']
69+
return typeof tier1ReachabilityScanId === 'string' && tier1ReachabilityScanId.length > 0
70+
? tier1ReachabilityScanId
71+
: undefined
7572
}

0 commit comments

Comments
 (0)