Skip to content

Commit 3bb1a0d

Browse files
committed
Add try-catch to git reset for optimize pnpm tests
1 parent 3d151d5 commit 3bb1a0d

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

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

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ describe('socket optimize - pnpm versions', { timeout: 60_000 }, async () => {
2828

2929
beforeEach(async () => {
3030
// Reset fixtures to their committed state (package.json and pnpm-lock.yaml).
31-
await spawn('git', ['checkout', 'HEAD', '--', '.'], {
32-
cwd: pnpm8FixtureDir,
33-
stdio: 'ignore',
34-
})
31+
try {
32+
await spawn('git', ['checkout', 'HEAD', '--', '.'], {
33+
cwd: pnpm8FixtureDir,
34+
stdio: 'ignore',
35+
})
36+
} catch {}
3537
// Ensure pnpm v8 is installed in the fixture.
3638
// Skip if pnpm is not available globally (e.g., Windows CI).
3739
try {
@@ -53,10 +55,12 @@ describe('socket optimize - pnpm versions', { timeout: 60_000 }, async () => {
5355

5456
afterEach(async () => {
5557
// Reset fixtures to their committed state after each test.
56-
await spawn('git', ['checkout', 'HEAD', '--', '.'], {
57-
cwd: pnpm8FixtureDir,
58-
stdio: 'ignore',
59-
})
58+
try {
59+
await spawn('git', ['checkout', 'HEAD', '--', '.'], {
60+
cwd: pnpm8FixtureDir,
61+
stdio: 'ignore',
62+
})
63+
} catch {}
6064
})
6165

6266
it(
@@ -158,10 +162,12 @@ describe('socket optimize - pnpm versions', { timeout: 60_000 }, async () => {
158162

159163
beforeEach(async () => {
160164
// Reset fixtures to their committed state (package.json and pnpm-lock.yaml).
161-
await spawn('git', ['checkout', 'HEAD', '--', '.'], {
162-
cwd: pnpm9FixtureDir,
163-
stdio: 'ignore',
164-
})
165+
try {
166+
await spawn('git', ['checkout', 'HEAD', '--', '.'], {
167+
cwd: pnpm9FixtureDir,
168+
stdio: 'ignore',
169+
})
170+
} catch {}
165171
// Ensure pnpm v9 is installed in the fixture.
166172
// Skip if pnpm is not available globally (e.g., Windows CI).
167173
try {
@@ -183,10 +189,12 @@ describe('socket optimize - pnpm versions', { timeout: 60_000 }, async () => {
183189

184190
afterEach(async () => {
185191
// Reset fixtures to their committed state after each test.
186-
await spawn('git', ['checkout', 'HEAD', '--', '.'], {
187-
cwd: pnpm9FixtureDir,
188-
stdio: 'ignore',
189-
})
192+
try {
193+
await spawn('git', ['checkout', 'HEAD', '--', '.'], {
194+
cwd: pnpm9FixtureDir,
195+
stdio: 'ignore',
196+
})
197+
} catch {}
190198
})
191199

192200
it(

0 commit comments

Comments
 (0)