Skip to content

Commit

Permalink
fix: factorize cache folders
Browse files Browse the repository at this point in the history
  • Loading branch information
vscaiceanu-1a committed Jun 12, 2024
1 parent 47ed2d0 commit 38a2dea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/@o3r/test-helpers/src/prepare-test-env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execFileSync, ExecSyncOptions } from 'node:child_process';
import { execFileSync, execSync, ExecSyncOptions } from 'node:child_process';
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs';
import * as path from 'node:path';
import type { PackageJson } from 'type-fest';
Expand Down
13 changes: 5 additions & 8 deletions packages/@o3r/test-helpers/src/utilities/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ export function setPackagerManagerConfig(options: PackageManagerConfig, execAppO
execFileSync('yarn', ['config', 'set', '@o3r:registry', options.registry], execOptions);
execFileSync('yarn', ['config', 'set', 'unsafeHttpWhitelist', '127.0.0.1'], execOptions);
}
const cacheFolder = 'cache-folder';
const globalFolder = 'global-folder';
const ignoreRootCheckConfig = '--add.ignore-workspace-root-check';
const yarnRcPath = join(execOptions.cwd as string, '.yarnrc');

Expand All @@ -281,12 +279,11 @@ export function setPackagerManagerConfig(options: PackageManagerConfig, execAppO
appendFileSync(yarnRcPath, `\n${ignoreRootCheckConfig} true`);
}
if (options.globalFolderPath) {
if (!content.includes(cacheFolder)) {
appendFileSync(yarnRcPath, `\n${cacheFolder} "${posix.join(options.globalFolderPath.split(sep).join(posix.sep), 'yarn1-cache', options.packageScope || '')}"`);
}
if (!content.includes(globalFolder)) {
appendFileSync(yarnRcPath, `\n${globalFolder} "${posix.join(options.globalFolderPath.split(sep).join(posix.sep), 'yarn1-global', options.packageScope || '')}"`);
}
['cache-folder', 'global-folder'].forEach(folder => {
if (!content.includes(folder)) {
appendFileSync(yarnRcPath, `\n${folder} "${posix.join(options.globalFolderPath!.split(sep).join(posix.sep), `yarn1-${folder}`, options.packageScope || '')}"`);
}
});
}
} else {
console.warn(`File not found at '${yarnRcPath}'.`);
Expand Down

0 comments on commit 38a2dea

Please sign in to comment.