Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 47 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101894,6 +101894,37 @@ const install = () => {
}
}

/**
* Runs an explicit "cypress install" after the dependencies have been
* installed. This downloads the Cypress binary when it is missing and is a
* no-op when it is already present.
*
* Package managers may no longer run a dependency's `postinstall` script by
* default, which means the script that normally downloads the Cypress binary
* no longer runs during a package-manager install. Running the install
* explicitly keeps the binary available on a cold cache regardless of package
* manager.
*
* Like "cypress verify" and "cypress cache list", this is invoked via npx for
* all package managers so the Cypress binary is resolved consistently.
*/
const installCypressBinary = () => {
debug('installing Cypress binary')

if (isCypressBinarySkipped()) {
debug('Skipping Cypress install, binary installation is disabled')
return Promise.resolve()
}

return io.which('npx', true).then((npxPath) => {
return exec.exec(
quote(npxPath),
['cypress', 'install'],
cypressCommandOptions
)
})
}

const listCypressBinaries = () => {
debug(
`Cypress versions in the cache folder ${CYPRESS_CACHE_FOLDER}`
Expand Down Expand Up @@ -102628,19 +102659,22 @@ const installMaybe = () => {

return install().then(() => {
debug('install has finished')
return listCypressBinaries().then(() => {
if (npmCacheHit && cypressCacheHit) {
debug('no need to verify Cypress binary or save caches')
return Promise.resolve(undefined)
}

debug('verifying Cypress binary')
const saveNpmPromise = packageManagerCacheEnabled
? saveCachedNpm()
: Promise.resolve(undefined)
return verifyCypressBinary()
.then(() => saveNpmPromise)
.then(saveCachedCypressBinary)
return installCypressBinary().then(() => {
debug('Cypress binary install has finished')
return listCypressBinaries().then(() => {
if (npmCacheHit && cypressCacheHit) {
debug('no need to verify Cypress binary or save caches')
return Promise.resolve(undefined)
}

debug('verifying Cypress binary')
const saveNpmPromise = packageManagerCacheEnabled
? saveCachedNpm()
: Promise.resolve(undefined)
return verifyCypressBinary()
.then(() => saveNpmPromise)
.then(saveCachedCypressBinary)
})
})
})
})
Expand Down
58 changes: 46 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,37 @@ const install = () => {
}
}

/**
* Runs an explicit "cypress install" after the dependencies have been
* installed. This downloads the Cypress binary when it is missing and is a
* no-op when it is already present.
*
* Package managers may no longer run a dependency's `postinstall` script by
* default, which means the script that normally downloads the Cypress binary
* no longer runs during a package-manager install. Running the install
* explicitly keeps the binary available on a cold cache regardless of package
* manager.
*
* Like "cypress verify" and "cypress cache list", this is invoked via npx for
* all package managers so the Cypress binary is resolved consistently.
*/
const installCypressBinary = () => {
debug('installing Cypress binary')

if (isCypressBinarySkipped()) {
debug('Skipping Cypress install, binary installation is disabled')
return Promise.resolve()
}

return io.which('npx', true).then((npxPath) => {
return exec.exec(
quote(npxPath),
['cypress', 'install'],
cypressCommandOptions
)
})
}

const listCypressBinaries = () => {
debug(
`Cypress versions in the cache folder ${CYPRESS_CACHE_FOLDER}`
Expand Down Expand Up @@ -1007,19 +1038,22 @@ const installMaybe = () => {

return install().then(() => {
debug('install has finished')
return listCypressBinaries().then(() => {
if (npmCacheHit && cypressCacheHit) {
debug('no need to verify Cypress binary or save caches')
return Promise.resolve(undefined)
}
return installCypressBinary().then(() => {
debug('Cypress binary install has finished')
return listCypressBinaries().then(() => {
if (npmCacheHit && cypressCacheHit) {
debug('no need to verify Cypress binary or save caches')
return Promise.resolve(undefined)
}

debug('verifying Cypress binary')
const saveNpmPromise = packageManagerCacheEnabled
? saveCachedNpm()
: Promise.resolve(undefined)
return verifyCypressBinary()
.then(() => saveNpmPromise)
.then(saveCachedCypressBinary)
debug('verifying Cypress binary')
const saveNpmPromise = packageManagerCacheEnabled
? saveCachedNpm()
: Promise.resolve(undefined)
return verifyCypressBinary()
.then(() => saveNpmPromise)
.then(saveCachedCypressBinary)
})
})
})
})
Expand Down