Skip to content

Commit 7489561

Browse files
tomasbjerreBlue Fmjhenkes
authored
feat: including version in CYPRESS_DOWNLOAD_PATH_TEMPLATE (refs #5141 #16976 #22864) (#23194)
Co-authored-by: Blue F <blue@cypress.io> Co-authored-by: Matt Henkes <mjhenkes@gmail.com>
1 parent 7dd4a14 commit 7489561

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

cli/__snapshots__/download_spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ exports['desktop url from template'] = `
4545
https://download.cypress.io/desktop/0.20.2/OS-ARCH/cypress.zip
4646
`
4747

48+
exports['desktop url from template with version'] = `
49+
https://mycompany/0.20.2/OS-ARCH/cypress.zip
50+
`
51+
4852
exports['desktop url from template with escaped dollar sign'] = `
4953
https://download.cypress.io/desktop/0.20.2/OS-ARCH/cypress.zip
5054
`

cli/lib/tasks/download.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const getCA = () => {
6060
})
6161
}
6262

63-
const prepend = (arch, urlPath) => {
63+
const prepend = (arch, urlPath, version) => {
6464
const endpoint = url.resolve(getBaseUrl(), urlPath)
6565
const platform = os.platform()
6666
const pathTemplate = util.getEnv('CYPRESS_DOWNLOAD_PATH_TEMPLATE', true)
@@ -71,6 +71,7 @@ const prepend = (arch, urlPath) => {
7171
.replace(/\\?\$\{endpoint\}/, endpoint)
7272
.replace(/\\?\$\{platform\}/, platform)
7373
.replace(/\\?\$\{arch\}/, arch)
74+
.replace(/\\?\$\{version\}/, version)
7475
)
7576
: `${endpoint}?platform=${platform}&arch=${arch}`
7677
}
@@ -82,7 +83,9 @@ const getUrl = (arch, version) => {
8283
return version
8384
}
8485

85-
return version ? prepend(arch, `desktop/${version}`) : prepend(arch, 'desktop')
86+
const urlPath = version ? `desktop/${version}` : 'desktop'
87+
88+
return prepend(arch, urlPath, version)
8689
}
8790

8891
const statusMessage = (err) => {

cli/test/lib/tasks/download_spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ describe('lib/tasks/download', function () {
7474
snapshot('desktop url from template', normalize(url))
7575
})
7676

77+
it('returns custom url from template with version', () => {
78+
process.env.CYPRESS_DOWNLOAD_PATH_TEMPLATE = 'https://mycompany/${version}/${platform}-${arch}/cypress.zip'
79+
const url = download.getUrl('ARCH', '0.20.2')
80+
81+
snapshot('desktop url from template with version', normalize(url))
82+
})
83+
7784
it('returns custom url from template with escaped dollar sign', () => {
7885
process.env.CYPRESS_DOWNLOAD_PATH_TEMPLATE = '\\${endpoint}/\\${platform}-\\${arch}/cypress.zip'
7986
const url = download.getUrl('ARCH', '0.20.2')

0 commit comments

Comments
 (0)