INNER CODE UNIT · TypeScript
createLastKnownGoodFile
nodejs/corepack · sources/Engine.ts:74
async function createLastKnownGoodFile(lastKnownGood: Record<string, string>) {
const content = `${JSON.stringify(lastKnownGood, null, 2)}\n`;
await fs.promises.mkdir(folderUtils.getCorepackHomeFolder(), {recursive: true});
await fs.promises.writeFile(getLastKnownGoodFilePath(), content, `utf8`);
}
export function getLastKnownGoodFromFileContent(lastKnownGood: Record<string, string>, packageManager: string) {
if (Object.hasOwn(lastKnownGood, packageManager))
return lastKnownGood[packageManager];
return undefined;
}
export async function activatePackageManager(lastKnownGood: Record<string, string>, locator: Locator) {
if (lastKnownGood[locator.name] === locator.reference) {
debugUtils.log(`${locator.name}@${locator.reference} is already Last Known Good version`);
return;
}