mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-07 06:59:49 -06:00
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
const os = require('os')
|
|
const getWindowsProxy = require('@cypress/get-windows-proxy')
|
|
|
|
module.exports = {
|
|
_getWindowsProxy () {
|
|
return getWindowsProxy()
|
|
},
|
|
|
|
_normalizeEnvironmentProxy () {
|
|
if (!process.env.HTTPS_PROXY) {
|
|
// request library will use HTTP_PROXY as a fallback for HTTPS urls, but
|
|
// proxy-from-env will not, so let's just force it to fall back like this
|
|
process.env.HTTPS_PROXY = process.env.HTTP_PROXY
|
|
}
|
|
|
|
if (!process.env.NO_PROXY) {
|
|
// don't proxy localhost, to match Chrome's default behavior and user expectation
|
|
process.env.NO_PROXY = 'localhost'
|
|
}
|
|
},
|
|
|
|
loadSystemProxySettings () {
|
|
if (process.env.HTTP_PROXY !== undefined) {
|
|
this._normalizeEnvironmentProxy()
|
|
|
|
return
|
|
}
|
|
|
|
if (os.platform() === 'win32') {
|
|
const windowsProxy = this._getWindowsProxy()
|
|
|
|
if (windowsProxy) {
|
|
process.env.HTTP_PROXY = process.env.HTTPS_PROXY = windowsProxy.httpProxy
|
|
process.env.NO_PROXY = process.env.NO_PROXY || windowsProxy.noProxy
|
|
}
|
|
|
|
this._normalizeEnvironmentProxy()
|
|
|
|
return 'win32'
|
|
}
|
|
},
|
|
}
|