mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-06 20:20:44 +00:00
930cf6633c
fix: Additional vi.mock path corrections and prettier formatting
24 lines
753 B
TypeScript
24 lines
753 B
TypeScript
import { logger } from '../../../../logger/index.ts';
|
|
import { readLocalFile } from '../../../../util/fs/index.ts';
|
|
import { PackageLock } from '../schema.ts';
|
|
import type { LockFile } from './types.ts';
|
|
|
|
export async function getNpmLock(filePath: string): Promise<LockFile> {
|
|
const lockfileContent = await readLocalFile(filePath, 'utf8');
|
|
if (!lockfileContent) {
|
|
logger.debug({ filePath }, 'Npm: unable to read lockfile');
|
|
return { lockedVersions: {} };
|
|
}
|
|
|
|
const parsedLockfile = PackageLock.safeParse(lockfileContent);
|
|
if (!parsedLockfile.success) {
|
|
logger.debug(
|
|
{ filePath, err: parsedLockfile.error },
|
|
'Npm: unable to parse lockfile',
|
|
);
|
|
return { lockedVersions: {} };
|
|
}
|
|
|
|
return parsedLockfile.data;
|
|
}
|