Skip to content

Commit 8f2965f

Browse files
caohuilinKyrieLii
authored andcommitted
fix: yarn install error
1 parent c0cf4d8 commit 8f2965f

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

tests/generator/module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os from 'os';
12
import path from 'path';
23
import { getModuleCases, getModuleNewCases } from '@modern-js/generator-cases';
34
import { fs, nanoid, semver } from '@modern-js/utils';
@@ -130,6 +131,10 @@ async function runModuleNewCommand(
130131
const params = ['install', '--ignore-scripts', '--force'];
131132
const packageManager = getPackageManager(project);
132133
if (isNode16 || project.includes('pnpm')) {
134+
if (packageManager === 'yarn') {
135+
params.push('--cache-folder');
136+
params.push(path.join(os.tmpdir(), project, 'yarn-cache'));
137+
}
133138
await execaWithStreamLog(packageManager, params, {
134139
cwd,
135140
});

tests/generator/monorepo.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ async function runMonorepoNewCommand(
135135
},
136136
},
137137
);
138-
if (packageManager === 'pnpm') {
139-
await execaWithStreamLog('pnpm', ['install'], {
140-
cwd,
141-
});
142-
}
143138
}
144139
}
145140

tests/generator/mwa.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os from 'os';
12
import path from 'path';
23
import { getMWACases, getMWANewCases } from '@modern-js/generator-cases';
34
import { fs, nanoid, semver } from '@modern-js/utils';
@@ -175,6 +176,10 @@ async function runMWANewCommand(
175176
const params = ['install', '--ignore-scripts', '--force'];
176177
const packageManager = getPackageManager(project);
177178
if (isNode16 || project.includes('pnpm')) {
179+
if (packageManager === 'yarn') {
180+
params.push('--cache-folder');
181+
params.push(path.join(os.tmpdir(), project, 'yarn-cache'));
182+
}
178183
await execaWithStreamLog(packageManager, params, {
179184
cwd,
180185
});

tests/generator/utils/command.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os from 'os';
12
import path from 'path';
23
import { fs, semver } from '@modern-js/utils';
34
import { execaWithStreamLog, getPackageManager } from './tools';
@@ -88,6 +89,10 @@ export async function runInstallAndBuildProject(type: string, tmpDir: string) {
8889
const isNode16 = semver.gte(process.versions.node, '16.0.0');
8990
const params = ['install', '--ignore-scripts', '--force'];
9091
if (isNode16 || project.includes('pnpm')) {
92+
if (packageManager === 'yarn') {
93+
params.push('--cache-folder');
94+
params.push(path.join(os.tmpdir(), project, 'yarn-cache'));
95+
}
9196
await execaWithStreamLog(packageManager, params, {
9297
cwd: path.join(tmpDir, project),
9398
});

0 commit comments

Comments
 (0)