mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-02 10:33:39 +00:00
930cf6633c
fix: Additional vi.mock path corrections and prettier formatting
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { logger } from '../../../../logger/index.ts';
|
|
import {
|
|
cachePathExists,
|
|
outputCacheFile,
|
|
readCacheFile,
|
|
} from '../../../fs/index.ts';
|
|
import { getLocalCacheFileName } from '../common.ts';
|
|
import type { RepoCacheRecord } from '../schema.ts';
|
|
import { RepoCacheBase } from './base.ts';
|
|
|
|
export class RepoCacheLocal extends RepoCacheBase {
|
|
constructor(repository: string, fingerprint: string) {
|
|
super(repository, fingerprint);
|
|
}
|
|
|
|
protected async read(): Promise<string | null> {
|
|
const cacheFileName = this.getCacheFileName();
|
|
try {
|
|
// suppress debug logs with errors
|
|
if (!(await cachePathExists(cacheFileName))) {
|
|
return null;
|
|
}
|
|
return await readCacheFile(cacheFileName, 'utf8');
|
|
} catch (err) {
|
|
logger.debug({ err, cacheFileName }, 'Repository local cache not found');
|
|
}
|
|
return null;
|
|
}
|
|
|
|
protected async write(data: RepoCacheRecord): Promise<void> {
|
|
const cacheFileName = this.getCacheFileName();
|
|
await outputCacheFile(cacheFileName, JSON.stringify(data));
|
|
}
|
|
|
|
private getCacheFileName(): string {
|
|
return getLocalCacheFileName(this.platform, this.repository);
|
|
}
|
|
}
|