Skip to content

Commit 78c250f

Browse files
committed
Fix optimize test on Windows
1 parent 094bd01 commit 78c250f

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

src/commands/optimize/cmd-optimize-pnpm-versions.test.mts

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import constants, {
1111
FLAG_CONFIG,
1212
FLAG_DRY_RUN,
1313
FLAG_SILENT,
14-
FLAG_VERSION,
1514
PNPM,
1615
PNPM_LOCK_YAML,
1716
} from '../../../src/constants.mts'
@@ -25,7 +24,7 @@ describe('socket optimize - pnpm versions', { timeout: 60_000 }, async () => {
2524
const { binCliPath } = constants
2625

2726
describe('pnpm v8', () => {
28-
const pnpm8BinPath = path.join(pnpm8FixtureDir, 'node_modules/.bin')
27+
const pnpm8BinPath = path.join(pnpm8FixtureDir, 'node_modules', '.bin')
2928

3029
beforeEach(async () => {
3130
// Reset fixtures to their committed state (package.json and pnpm-lock.yaml).
@@ -34,19 +33,22 @@ describe('socket optimize - pnpm versions', { timeout: 60_000 }, async () => {
3433
stdio: 'ignore',
3534
})
3635
// Ensure pnpm v8 is installed in the fixture.
37-
await spawn(
38-
PNPM,
39-
[
40-
'install',
41-
FLAG_SILENT,
42-
'--config.confirmModulesPurge=false',
43-
'--no-frozen-lockfile',
44-
],
45-
{
46-
cwd: pnpm8FixtureDir,
47-
stdio: 'ignore',
48-
},
49-
)
36+
// Skip if pnpm is not available globally (e.g., Windows CI).
37+
try {
38+
await spawn(
39+
PNPM,
40+
[
41+
'install',
42+
FLAG_SILENT,
43+
'--config.confirmModulesPurge=false',
44+
'--no-frozen-lockfile',
45+
],
46+
{
47+
cwd: pnpm8FixtureDir,
48+
stdio: 'ignore',
49+
},
50+
)
51+
} catch {}
5052
})
5153

5254
afterEach(async () => {
@@ -152,7 +154,7 @@ describe('socket optimize - pnpm versions', { timeout: 60_000 }, async () => {
152154
})
153155

154156
describe('pnpm v9', () => {
155-
const pnpm9BinPath = path.join(pnpm9FixtureDir, 'node_modules/.bin')
157+
const pnpm9BinPath = path.join(pnpm9FixtureDir, 'node_modules', '.bin')
156158

157159
beforeEach(async () => {
158160
// Reset fixtures to their committed state (package.json and pnpm-lock.yaml).
@@ -161,19 +163,22 @@ describe('socket optimize - pnpm versions', { timeout: 60_000 }, async () => {
161163
stdio: 'ignore',
162164
})
163165
// Ensure pnpm v9 is installed in the fixture.
164-
await spawn(
165-
PNPM,
166-
[
167-
'install',
168-
FLAG_SILENT,
169-
'--config.confirmModulesPurge=false',
170-
'--no-frozen-lockfile',
171-
],
172-
{
173-
cwd: pnpm9FixtureDir,
174-
stdio: 'ignore',
175-
},
176-
)
166+
// Skip if pnpm is not available globally (e.g., Windows CI).
167+
try {
168+
await spawn(
169+
PNPM,
170+
[
171+
'install',
172+
FLAG_SILENT,
173+
'--config.confirmModulesPurge=false',
174+
'--no-frozen-lockfile',
175+
],
176+
{
177+
cwd: pnpm9FixtureDir,
178+
stdio: 'ignore',
179+
},
180+
)
181+
} catch {}
177182
})
178183

179184
afterEach(async () => {

0 commit comments

Comments
 (0)