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

refactor(cocoapods): Use util function for cache dir creation (#10587)

parent b53e5e40
No related branches found
No related tags found
No related merge requests found
...@@ -4,13 +4,13 @@ import { TEMPORARY_ERROR } from '../../constants/error-messages'; ...@@ -4,13 +4,13 @@ import { TEMPORARY_ERROR } from '../../constants/error-messages';
import { logger } from '../../logger'; import { logger } from '../../logger';
import { ExecOptions, exec } from '../../util/exec'; import { ExecOptions, exec } from '../../util/exec';
import { import {
ensureCacheDir,
getSiblingFileName, getSiblingFileName,
readLocalFile, readLocalFile,
writeLocalFile, writeLocalFile,
} from '../../util/fs'; } from '../../util/fs';
import { getRepoStatus } from '../../util/git'; import { getRepoStatus } from '../../util/git';
import type { UpdateArtifact, UpdateArtifactsResult } from '../types'; import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
import { getCocoaPodsHome } from './utils';
const pluginRegex = /^\s*plugin\s*(['"])(?<plugin>[^'"]+)\1/; const pluginRegex = /^\s*plugin\s*(['"])(?<plugin>[^'"]+)\1/;
...@@ -67,11 +67,14 @@ export async function updateArtifacts({ ...@@ -67,11 +67,14 @@ export async function updateArtifacts({
); );
const tagConstraint = match?.groups?.cocoapodsVersion ?? null; const tagConstraint = match?.groups?.cocoapodsVersion ?? null;
const cacheDir = await ensureCacheDir('./others/cocoapods', 'CP_HOME_DIR');
logger.debug(`Using cocoapods home ${cacheDir}`);
const cmd = [...getPluginCommands(newPackageFileContent), 'pod install']; const cmd = [...getPluginCommands(newPackageFileContent), 'pod install'];
const execOptions: ExecOptions = { const execOptions: ExecOptions = {
cwdFile: packageFileName, cwdFile: packageFileName,
extraEnv: { extraEnv: {
CP_HOME_DIR: await getCocoaPodsHome(config), CP_HOME_DIR: cacheDir,
}, },
docker: { docker: {
image: 'cocoapods', image: 'cocoapods',
......
import { join } from 'upath';
import { getAdminConfig } from '../../config/admin';
import { logger } from '../../logger';
import { ensureDir } from '../../util/fs';
import type { UpdateArtifactsConfig } from '../types';
export async function getCocoaPodsHome(
config: UpdateArtifactsConfig
): Promise<string> {
const adminCacheDir = getAdminConfig().cacheDir;
const cacheDir =
process.env.CP_HOME_DIR || join(adminCacheDir, './others/cocoapods');
await ensureDir(cacheDir);
logger.debug(`Using cocoapods home ${cacheDir}`);
return cacheDir;
}
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