INNER CODE UNIT · TypeScript

getLastKnownGood

nodejs/corepack · sources/Engine.ts:37

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;
  }

  try {
    const parsed = JSON.parse(raw);
    if (!parsed) {
      debugUtils.log(`Invalid LastKnowGood file in Corepack home (JSON parsable, but falsy)`);
      return {};
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…