{"version":3,"sources":["../../src/utils/snapshot.ts"],"sourcesContent":["import * as fse from \"fs-extra\";\nimport { basename, dirname, resolve } from \"path\";\n\n// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/63859#issuecomment-1541956062\nconst { ensureFileSync, readJsonSync, writeJsonSync } = fse;\n\nexport const getTypeSnapshot = (filename: string, snapshotName: string) => {\n\tconst snapshotPath = getSnapshotPath(filename);\n\tconst json = readJsonSync(snapshotPath, { throws: false }) as\n\t\t| Record<string, string>\n\t\t| undefined;\n\tif (!json) {\n\t\treturn;\n\t}\n\n\treturn json[snapshotName];\n};\n\nexport const updateTypeSnapshot = (\n\tfilename: string,\n\tsnapshotName: string,\n\tactualType: null | string,\n) => {\n\tconst snapshotPath = getSnapshotPath(filename);\n\tensureFileSync(snapshotPath);\n\n\tconst json =\n\t\t(readJsonSync(snapshotPath, { throws: false }) as\n\t\t\t| Record<string, null | string>\n\t\t\t| undefined) ?? {};\n\tjson[snapshotName] = actualType;\n\twriteJsonSync(snapshotPath, json, { spaces: 2 });\n};\n\nfunction getSnapshotPath(filename: string) {\n\tconst directory = dirname(filename);\n\treturn resolve(\n\t\tdirectory,\n\t\t\"__type-snapshots__\",\n\t\t`${basename(filename)}.snap.json`,\n\t);\n}\n"],"mappings":";AAAA,YAAY,SAAS;AACrB,SAAS,UAAU,SAAS,eAAe;AAG3C,MAAM,EAAE,gBAAgB,cAAc,cAAc,IAAI;AAEjD,MAAM,kBAAkB,CAAC,UAAkB,iBAAyB;AAC1E,QAAM,eAAe,gBAAgB,QAAQ;AAC7C,QAAM,OAAO,aAAa,cAAc,EAAE,QAAQ,MAAM,CAAC;AAGzD,MAAI,CAAC,MAAM;AACV;AAAA,EACD;AAEA,SAAO,KAAK,YAAY;AACzB;AAEO,MAAM,qBAAqB,CACjC,UACA,cACA,eACI;AACJ,QAAM,eAAe,gBAAgB,QAAQ;AAC7C,iBAAe,YAAY;AAE3B,QAAM,OACJ,aAAa,cAAc,EAAE,QAAQ,MAAM,CAAC,KAE5B,CAAC;AACnB,OAAK,YAAY,IAAI;AACrB,gBAAc,cAAc,MAAM,EAAE,QAAQ,EAAE,CAAC;AAChD;AAEA,SAAS,gBAAgB,UAAkB;AAC1C,QAAM,YAAY,QAAQ,QAAQ;AAClC,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,GAAG,SAAS,QAAQ,CAAC;AAAA,EACtB;AACD;","names":[]}