Files
cypress/packages/server/lib/controllers/client.js
Zach Bloomquist d01932bf75 fix: retry on EMFILE always, lint sync FS calls (#22175)
* fix: use graceful-fs always, warn in development on sync calls

* skip prop linting in some dirs

* eslint rules

* use AST-based lint rule instead

* comment

* ignore existsSync

* run without nextTick

* remove dev warning code

* fix order

* register TS first

* fix tests

* fix test

* cover new call site

* fix new test
2022-06-16 14:35:31 +10:00

26 lines
727 B
JavaScript

const debug = require('debug')('cypress:server:controllers:client')
const socketIo = require('@packages/socket')
// hold onto the client source + version in memory
const clientSourcePath = socketIo.getPathToClientSource()
const clientVersion = socketIo.getClientVersion()
module.exports = {
handle (req, res) {
const etag = req.get('if-none-match')
debug('serving socket.io client %o', { etag, clientVersion })
if (etag && (etag === clientVersion)) {
return res.sendStatus(304)
}
return res
.type('application/javascript')
.set('ETag', clientVersion)
.status(200)
// TODO: replace this entire file and sendFile call with `express.static`.
.sendFile(clientSourcePath)
},
}