Minor changes
This commit is contained in:
@ -53,25 +53,19 @@ async function getNpmProxyConfig(): Promise<Pick<FetchOptions, "proxy" | "noProx
|
|||||||
return { proxy, noProxy };
|
return { proxy, noProxy };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadAndUnzip({
|
export async function downloadAndUnzip(params: { url: string; destDirPath: string; pathOfDirToExtractInArchive?: string }) {
|
||||||
url,
|
const { url, destDirPath, pathOfDirToExtractInArchive } = params;
|
||||||
destDirPath,
|
|
||||||
pathOfDirToExtractInArchive
|
|
||||||
}: {
|
|
||||||
url: string;
|
|
||||||
destDirPath: string;
|
|
||||||
pathOfDirToExtractInArchive?: string;
|
|
||||||
}) {
|
|
||||||
const downloadHash = hash(JSON.stringify({ url })).substring(0, 15);
|
const downloadHash = hash(JSON.stringify({ url })).substring(0, 15);
|
||||||
const projectRoot = getProjectRoot();
|
const projectRoot = getProjectRoot();
|
||||||
const cacheRoot = process.env.XDG_CACHE_HOME ?? `${projectRoot}/node_modules/.cache`;
|
const cacheRoot = process.env.XDG_CACHE_HOME ?? pathJoin(projectRoot, "node_modules", ".cache");
|
||||||
const zipFilePath = pathJoin(cacheRoot, "keycloakify", "zip", `_${downloadHash}.zip`);
|
const zipFilePath = pathJoin(cacheRoot, "keycloakify", "zip", `_${downloadHash}.zip`);
|
||||||
const extractDirPath = pathJoin(cacheRoot, "keycloakify", "unzip", `_${downloadHash}`);
|
const extractDirPath = pathJoin(cacheRoot, "keycloakify", "unzip", `_${downloadHash}`);
|
||||||
|
|
||||||
if (!(await exists(zipFilePath))) {
|
if (!(await exists(zipFilePath))) {
|
||||||
const proxyOpts = await getNpmProxyConfig();
|
const proxyOpts = await getNpmProxyConfig();
|
||||||
const response = await fetch(url, proxyOpts);
|
const response = await fetch(url, proxyOpts);
|
||||||
await mkdir(pathDirname(zipFilePath), { recursive: true });
|
await mkdir(pathDirname(zipFilePath), { "recursive": true });
|
||||||
/**
|
/**
|
||||||
* The correct way to fix this is to upgrade node-fetch beyond 3.2.5
|
* The correct way to fix this is to upgrade node-fetch beyond 3.2.5
|
||||||
* (see https://github.com/node-fetch/node-fetch/issues/1295#issuecomment-1144061991.)
|
* (see https://github.com/node-fetch/node-fetch/issues/1295#issuecomment-1144061991.)
|
||||||
|
Reference in New Issue
Block a user