[web] isolate cypress webpack caches (#33516)
GitOrigin-RevId: 65f8bf162df4fa3b67c8ac19f36fd578251e88f4
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
const path = require('path')
|
||||
|
||||
// Returns the cache subdirectory name for the current Cypress CT variant,
|
||||
// or null when CYPRESS_RESULTS is not set.
|
||||
// Throws if the derived basename is unsafe to prevent path traversal or
|
||||
// absolute-path escapes.
|
||||
function cypressCacheVariant() {
|
||||
if (!process.env.CYPRESS_RESULTS) return null
|
||||
const variant = path.basename(process.env.CYPRESS_RESULTS)
|
||||
if (
|
||||
!variant ||
|
||||
variant === '.' ||
|
||||
variant === '..' ||
|
||||
path.isAbsolute(variant)
|
||||
) {
|
||||
throw new Error(
|
||||
`CYPRESS_RESULTS must resolve to a safe basename; got "${process.env.CYPRESS_RESULTS}"`
|
||||
)
|
||||
}
|
||||
return variant
|
||||
}
|
||||
|
||||
module.exports = cypressCacheVariant
|
||||
@@ -1,9 +1,13 @@
|
||||
const fs = require('fs')
|
||||
const Path = require('path')
|
||||
const Settings = require('@overleaf/settings')
|
||||
const cypressCacheVariant = require('./cypress-cache-variant')
|
||||
|
||||
module.exports = function invalidateBabelCacheIfNeeded() {
|
||||
const cacheDir = Path.join(__dirname, '../../node_modules/.cache')
|
||||
// Use a unique subdirectory per Cypress CT variant to avoid parallel jobs
|
||||
// racing on the shared babel cache and state file.
|
||||
const suffix = cypressCacheVariant() ?? ''
|
||||
const cacheDir = Path.join(__dirname, '../../node_modules/.cache', suffix)
|
||||
const cachePath = Path.join(cacheDir, 'babel-loader')
|
||||
const statePath = Path.join(cacheDir, 'last-overleafModuleImports.json')
|
||||
let lastState = ''
|
||||
|
||||
Reference in New Issue
Block a user