0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-01-11 13:48:55 +00:00
renovatebot_renovate/lib/modules/datasource/deb/file.ts
oxdev03 c3958c9bd6
feat(datasource): add debian datasource (#30071)
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Aleksandr Mezin <mezin.alexander@gmail.com>
Co-authored-by: Jasmin Müller <9011011+jazzlyn@users.noreply.github.com>
2024-08-28 17:26:56 +00:00

37 lines
1.2 KiB
TypeScript

import { createUnzip } from 'zlib';
import * as fs from '../../../util/fs';
/**
* Extracts the specified compressed file to the output file.
*
* @param compressedFile - The path to the compressed file.
* @param compression - The compression method used (currently only 'gz' is supported).
* @param outputFile - The path where the extracted content will be stored.
* @throws Will throw an error if the compression method is unknown.
*/
export async function extract(
compressedFile: string,
compression: string,
outputFile: string,
): Promise<void> {
if (compression === 'gz') {
const source = fs.createCacheReadStream(compressedFile);
const destination = fs.createCacheWriteStream(outputFile);
await fs.pipeline(source, createUnzip(), destination);
} else {
throw new Error(`Unsupported compression standard '${compression}'`);
}
}
/**
* Checks if the file exists and retrieves its creation time.
*
* @param filePath - The path to the file.
* @returns The creation time if the file exists, otherwise undefined.
*/
export async function getFileCreationTime(
filePath: string,
): Promise<Date | undefined> {
const stats = await fs.statCacheFile(filePath);
return stats?.ctime;
}