Skip to content

Commit 4ae0d51

Browse files
committed
Use HIDDEN_PACKAGE_LOCK
1 parent 6216463 commit 4ae0d51

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/utils/package-environment.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ import type { SemVer } from 'semver'
2525
const {
2626
BINARY_LOCK_EXT,
2727
BUN,
28+
HIDDEN_PACKAGE_LOCK,
2829
LOCK_EXT,
2930
NPM,
3031
NPM_BUGGY_OVERRIDES_PATCHED_VERSION,
32+
PACKAGE_JSON,
3133
PNPM,
3234
VLT,
3335
YARN,
@@ -195,10 +197,10 @@ export async function detectPackageEnvironment({
195197
}: DetectOptions = {}): Promise<EnvDetails | PartialEnvDetails> {
196198
let lockPath = await findUp(Object.keys(LOCKS), { cwd })
197199
let lockName = lockPath ? path.basename(lockPath) : undefined
198-
const isHiddenLockFile = lockName === '.package-lock.json'
200+
const isHiddenLockFile = lockName === HIDDEN_PACKAGE_LOCK
199201
const pkgJsonPath = lockPath
200-
? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`)
201-
: await findUp('package.json', { cwd })
202+
? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../${PACKAGE_JSON}`)
203+
: await findUp(PACKAGE_JSON, { cwd })
202204
const pkgPath =
203205
pkgJsonPath && existsSync(pkgJsonPath)
204206
? path.dirname(pkgJsonPath)
@@ -375,7 +377,7 @@ export async function detectAndValidatePackageEnvironment(
375377
return
376378
}
377379
if (details.pkgPath === undefined) {
378-
logger?.fail(cmdPrefixMessage(cmdName, 'No package.json found'))
380+
logger?.fail(cmdPrefixMessage(cmdName, `No ${PACKAGE_JSON} found`))
379381
return
380382
}
381383
if (prod && (details.agent === BUN || details.agent === YARN_BERRY)) {

0 commit comments

Comments
 (0)