INNER CODE UNIT · TypeScript
getLastKnownGoodFilePath
nodejs/corepack · sources/Engine.ts:31
function getLastKnownGoodFilePath() {
const lkg = path.join(folderUtils.getCorepackHomeFolder(), `lastKnownGood.json`);
debugUtils.log(`LastKnownGood file would be located at ${lkg}`);
return lkg;
}
export async function getLastKnownGood(): Promise<Record<string, string>> {
let raw: string;
try {
raw = await fs.promises.readFile(getLastKnownGoodFilePath(), `utf8`);
} catch (err) {
if ((err as NodeError)?.code === `ENOENT`) {
debugUtils.log(`No LastKnownGood version found in Corepack home.`);
return {};
}
throw err;
}