Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1x 1x 1x 1x 1x 1x 1x | import Path from "path";
import { rimraf as rmdir } from "rimraf";
import { glob } from "lib/helpers/glob";
import { stat, unlink } from "fs-extra";
export const getCacheRoot = (tmpPath: string) =>
Path.join(tmpPath, "_gbscache");
export const clearAppCache = async (tmpPath: string) => {
const cacheRoot = getCacheRoot(tmpPath);
await rmdir(cacheRoot);
};
export const clearAppCacheOlderThan = async (tmpPath: string, age: number) => {
const cacheRoot = getCacheRoot(tmpPath);
const files = await glob("**/*", {
cwd: cacheRoot,
absolute: true,
nodir: true,
});
const cutoffTime = Date.now() - age;
for (const file of files) {
try {
const stats = await stat(file);
if (stats.isFile() && stats.mtimeMs < cutoffTime) {
await unlink(file);
}
} catch {
// Ignore errors (e.g. file not found)
}
}
};
|