Skip to content
Snippets Groups Projects
Unverified Commit 11f89147 authored by Sergei Zharinov's avatar Sergei Zharinov Committed by GitHub
Browse files

refactor: Use exec util instead of obtaining env directly (#10584)

parent 7080a32e
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import * as fs from 'fs-extra';
import { isAbsolute, join, parse } from 'upath';
import { getAdminConfig } from '../../config/admin';
import { logger } from '../../logger';
import { getChildProcessEnv } from '../exec/env';
export * from './proxies';
......@@ -83,12 +84,16 @@ export async function ensureLocalDir(dirName: string): Promise<void> {
}
export async function ensureCacheDir(
dirName: string,
envPathVar?: string
adminCacheSubdir: string,
envCacheVar?: string
): Promise<string> {
const { cacheDir } = getAdminConfig();
const envCacheDirName = envPathVar ? process.env[envPathVar] : null;
const cacheDirName = envCacheDirName || join(cacheDir, dirName);
const { cacheDir: adminCacheDir } = getAdminConfig();
let envCacheDir = null;
if (envCacheVar) {
const env = getChildProcessEnv([envCacheVar]);
envCacheDir = env[envCacheVar];
}
const cacheDirName = envCacheDir || join(adminCacheDir, adminCacheSubdir);
await fs.ensureDir(cacheDirName);
return cacheDirName;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment