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

refactor(composer): Use util function for cache dir creation (#10581)

parent ca75f136
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,9 @@ describe('.updateArtifacts()', () => {
docker.resetPrefetchedImages();
hostRules.clear();
setAdminConfig(adminConfig);
fs.ensureCacheDir.mockResolvedValue(
join(adminConfig.cacheDir, './others/composer')
);
});
afterEach(() => {
setAdminConfig();
......
import is from '@sindresorhus/is';
import { quote } from 'shlex';
import upath from 'upath';
import { getAdminConfig } from '../../config/admin';
import {
SYSTEM_INSUFFICIENT_DISK_SPACE,
......@@ -15,7 +14,7 @@ import { logger } from '../../logger';
import { ExecOptions, exec } from '../../util/exec';
import {
deleteLocalFile,
ensureDir,
ensureCacheDir,
ensureLocalDir,
getSiblingFileName,
localPathExists,
......@@ -77,11 +76,10 @@ export async function updateArtifacts({
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
logger.debug(`composer.updateArtifacts(${packageFileName})`);
const { allowScripts, cacheDir: adminCacheDir } = getAdminConfig();
const cacheDir =
process.env.COMPOSER_CACHE_DIR ||
upath.join(adminCacheDir, './others/composer');
await ensureDir(cacheDir);
const cacheDir = await ensureCacheDir(
'./others/composer',
'COMPOSER_CACHE_DIR'
);
logger.debug(`Using composer cache ${cacheDir}`);
const lockFileName = packageFileName.replace(/\.json$/, '.lock');
......@@ -125,7 +123,7 @@ export async function updateArtifacts({
args += ' --ignore-platform-reqs';
}
args += ' --no-ansi --no-interaction';
if (!allowScripts || config.ignoreScripts) {
if (!getAdminConfig().allowScripts || config.ignoreScripts) {
args += ' --no-scripts --no-autoloader';
}
logger.debug({ cmd, args }, 'composer command');
......
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