Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

Commit 9fd176f

Browse files
committed
chore: fix ci prerelease and jest types
1 parent 7589a63 commit 9fd176f

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

pre-release-steps.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,22 @@ async function downloadAndWrite(fn: string): Promise<string> {
3333
async function downloadArtifacts(): Promise<string[]> {
3434
const releases = ['linux', 'linux-arm64', 'macos-x86_64', 'macos-arm64', 'windows.exe']
3535

36-
const promisesToExec: Array<Promise<string>> = []
36+
const promisesToExec: Array<Promise<string | null>> = []
3737
for (let i = 0; i < releases.length; i++) {
38-
promisesToExec.push(downloadAndWrite(`vrelease-${releases[i]}`))
38+
const artifact = `vrelease-${releases[i]}`
39+
promisesToExec.push(
40+
downloadAndWrite(artifact).catch((err: unknown) => {
41+
if (axios.isAxiosError(err) && err.response?.status === 404) {
42+
log(`missing artifact ${artifact}, skipping`)
43+
return null
44+
}
45+
throw err
46+
}),
47+
)
3948
}
4049

41-
return await Promise.all(promisesToExec)
50+
const artifacts = await Promise.all(promisesToExec)
51+
return artifacts.filter((artifact): artifact is string => artifact !== null)
4252
}
4353

4454
async function main(): Promise<void> {

tests/wrapper.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import path from 'node:path'
55

66
import { VRelease } from '../src/wrapper'
77

8-
jest.mock('child_process')
8+
jest.mock('node:child_process', () => ({
9+
spawn: jest.fn(),
10+
}))
911

1012
describe('VRelease:', () => {
1113
const vb = VRelease.builder
@@ -65,7 +67,7 @@ describe('VRelease:', () => {
6567
return jest.spyOn(proto, field).mockImplementation((): string => retval)
6668
}
6769

68-
const spawnSpy = jest.spyOn(cp, 'spawn')
70+
const spawnSpy = cp.spawn as jest.MockedFunction<typeof cp.spawn>
6971

7072
const setupSpawn = (
7173
exitCode: number | null = 0,
@@ -94,7 +96,7 @@ describe('VRelease:', () => {
9496
return proc
9597
},
9698
}
97-
return proc
99+
return proc as unknown as cp.ChildProcess
98100
}
99101

100102
if (once) {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"resolveJsonModule": true,
1313
"declaration": true,
1414
"lib": ["ES2020"],
15-
"types": ["node"]
15+
"types": ["node", "jest"]
1616
}
1717
}

0 commit comments

Comments
 (0)