Files
cypress/scripts/ensure-icons.js
Mike Plummer 91cbc6741c chore: Update Vite to 4.3.0 (#26553)
Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
2023-04-27 15:09:31 -05:00

33 lines
865 B
JavaScript

const fs = require('fs-extra')
const path = require('path')
function delay (n) {
return new Promise((resolve) => setTimeout(resolve, n))
}
async function waitUntilExists (dir, { freq, maxAttempts }, numAttempts = 0) {
const exists = await fs.pathExists(dir)
if (exists) {
return true
}
if (numAttempts > maxAttempts) {
throw Error(`Failed to detect path at ${dir} after ${maxAttempts}.`)
}
console.log(`[@packages/runner/webpack.config.ts]: ${dir} not found. Will check again in ${freq}ms. Attempt: ${numAttempts}/${maxAttempts}`)
await delay(freq)
return waitUntilExists(dir, { freq, maxAttempts }, numAttempts + 1)
}
async function waitUntilIconsBuilt () {
await waitUntilExists(path.join(__dirname, '..', 'packages', 'icons', 'dist', 'favicon'), { freq: 1000, maxAttempts: 10 })
}
module.exports = {
waitUntilIconsBuilt,
}