Current behavior:
A user env variable of CYPRESS_INSTALL_BINARY='' (an empty string) cannot override the npm config.
We want to run cypress only in CI, so we put a CYPRESS_INSTALL_BINARY=0 in PROJECT/.npmrc to avoid all our developers to download the cypress binary, which is a big cost considering our poor network. And then add a user env variable in CI to let it do download. Since cypress releases frequently, a fixed version like CYPRESS_INSTALL_BINARY=5.1.0 is not a good approach. But CYPRESS_INSTALL_BINARY='' is not working too.
Desired behavior:
Allow the user env variable of CYPRESS_INSTALL_BINARY='' to take precedence over npm config. Or add a new keyword of CYPRESS_INSTALL_BINARY=auto or something like that.
Test code to reproduce
- Add
CYPRESS_INSTALL_BINARY=0 in a project's .npmrc (or ~/.npmrc)
- Add
export CYPRESS_INSTALL_BINARY='' in shell profile (e.g. ~/.bash_profile)
- Run
npm install cypress
Possible fix
In https://github.com/cypress-io/cypress/blob/develop/cli/lib/util.js#L473
const envVar = process.env[varName]
// Instead of `if (envVar)`, prefer:
if (varName in process.env) {
result = envVar
}
Or we can add an extra option of allowEmptyVar for getEnv to avoid potential breaking for all other env variables.
Versions
Cypress: 5.1.0
Operation systems: Mac OS 10.15, CentOS 7
Current behavior:
A user env variable of
CYPRESS_INSTALL_BINARY=''(an empty string) cannot override the npm config.We want to run cypress only in CI, so we put a
CYPRESS_INSTALL_BINARY=0inPROJECT/.npmrcto avoid all our developers to download the cypress binary, which is a big cost considering our poor network. And then add a user env variable in CI to let it do download. Since cypress releases frequently, a fixed version likeCYPRESS_INSTALL_BINARY=5.1.0is not a good approach. ButCYPRESS_INSTALL_BINARY=''is not working too.Desired behavior:
Allow the user env variable of
CYPRESS_INSTALL_BINARY=''to take precedence over npm config. Or add a new keyword ofCYPRESS_INSTALL_BINARY=autoor something like that.Test code to reproduce
CYPRESS_INSTALL_BINARY=0in a project's.npmrc(or~/.npmrc)export CYPRESS_INSTALL_BINARY=''in shell profile (e.g.~/.bash_profile)npm install cypressPossible fix
In https://github.com/cypress-io/cypress/blob/develop/cli/lib/util.js#L473
Or we can add an extra option of
allowEmptyVarforgetEnvto avoid potential breaking for all other env variables.Versions
Cypress: 5.1.0
Operation systems: Mac OS 10.15, CentOS 7