Skip to content

Commit 2685f82

Browse files
feat: env to use path params in download url (#19526)
* feat: env to use path params in download url * feat: change env to url template * feat: fix snapshot Co-authored-by: Matt Henkes <[email protected]>
1 parent 3b23887 commit 2685f82

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

cli/__snapshots__/download_spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ https://download.cypress.io/desktop?platform=OS&arch=ARCH
4040
exports['specific version desktop url 1'] = `
4141
https://download.cypress.io/desktop/0.20.2?platform=OS&arch=ARCH
4242
`
43+
44+
exports['desktop url from template'] = `
45+
https://download.cypress.io/desktop/0.20.2/darwin-x64/cypress.zip
46+
`

cli/lib/tasks/download.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ const getCA = () => {
6464
const prepend = (urlPath) => {
6565
const endpoint = Url.resolve(getBaseUrl(), urlPath)
6666
const platform = os.platform()
67+
const pathTemplate = util.getEnv('CYPRESS_DOWNLOAD_PATH_TEMPLATE')
6768

68-
return `${endpoint}?platform=${platform}&arch=${arch()}`
69+
return pathTemplate
70+
? pathTemplate.replace('${endpoint}', endpoint).replace('${platform}', platform).replace('${arch}', arch())
71+
: `${endpoint}?platform=${platform}&arch=${arch()}`
6972
}
7073

7174
const getUrl = (version) => {

cli/test/lib/tasks/download_spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ describe('lib/tasks/download', function () {
6565
snapshot('specific version desktop url 1', normalize(url))
6666
})
6767

68+
it('returns custom url from template', () => {
69+
process.env.CYPRESS_DOWNLOAD_PATH_TEMPLATE = '${endpoint}/${platform}-${arch}/cypress.zip'
70+
const url = download.getUrl('0.20.2')
71+
72+
snapshot('desktop url from template', normalize(url))
73+
})
74+
6875
it('returns input if it is already an https link', () => {
6976
const url = 'https://somewhere.com'
7077
const result = download.getUrl(url)

0 commit comments

Comments
 (0)