1+ import { existsSync } from 'node:fs'
12import path from 'node:path'
23import process from 'node:process'
34
@@ -11,7 +12,7 @@ import { isObjectObject } from '@socketsecurity/registry/lib/objects'
1112import { readPackageJson } from '@socketsecurity/registry/lib/packages'
1213import { isNonEmptyString } from '@socketsecurity/registry/lib/strings'
1314
14- import { findUp , readFileBinary , readFileUtf8 , safeExistsSync } from './fs'
15+ import { findUp , readFileBinary , readFileUtf8 } from './fs'
1516import constants from '../constants'
1617
1718import type { EditablePackageJson } from '@socketsecurity/registry/lib/packages'
@@ -173,9 +174,10 @@ export async function detect({
173174 const pkgJsonPath = lockPath
174175 ? path . resolve ( lockPath , `${ isHiddenLockFile ? '../' : '' } ../package.json` )
175176 : await findUp ( 'package.json' , { cwd } )
176- const pkgPath = safeExistsSync ( pkgJsonPath )
177- ? path . dirname ( pkgJsonPath ! )
178- : undefined
177+ const pkgPath =
178+ pkgJsonPath && existsSync ( pkgJsonPath )
179+ ? path . dirname ( pkgJsonPath )
180+ : undefined
179181 const editablePkgJson = pkgPath
180182 ? await readPackageJson ( pkgPath , { editable : true } )
181183 : undefined
0 commit comments