Skip to content

Commit 1da9bb3

Browse files
fix ci
1 parent 5741042 commit 1da9bb3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packages/ui/scripts/run-cypress.cjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ if (fs.existsSync(defaultBinary)) {
3232
env.CYPRESS_RUN_BINARY = defaultBinary
3333
}
3434

35+
const platformBinarySegments =
36+
process.platform === 'darwin'
37+
? ['Cypress.app', 'Contents', 'MacOS', 'Cypress']
38+
: process.platform === 'win32'
39+
? ['Cypress', 'Cypress.exe']
40+
: ['Cypress', 'Cypress']
41+
42+
const cachedBinary = path.join(cacheDir, cypressVersion, ...platformBinarySegments)
43+
const runBinaryPath = env.CYPRESS_RUN_BINARY
3544
const args = process.argv.slice(2)
3645
const requestedCommand = args[0]
3746

@@ -65,6 +74,26 @@ function run(command, args, options = {}) {
6574
}
6675

6776
async function main() {
77+
const hasRunBinary = typeof runBinaryPath === 'string' && fs.existsSync(runBinaryPath)
78+
if (!fs.existsSync(cachedBinary) && !hasRunBinary) {
79+
console.info('Cypress binary missing from cache. Installing...')
80+
81+
const installResult = await run(process.execPath, [cypressBin, 'install'], {
82+
env,
83+
stdio: 'inherit',
84+
})
85+
86+
if (installResult.signal) {
87+
process.kill(process.pid, installResult.signal)
88+
return
89+
}
90+
91+
if ((installResult.code ?? 0) !== 0) {
92+
process.exit(installResult.code ?? 0)
93+
return
94+
}
95+
}
96+
6897
const cypressResult = await run(process.execPath, [cypressBin, ...args], {
6998
env,
7099
capture: true,

0 commit comments

Comments
 (0)