Skip to content

Commit

Permalink
feat: support CYPRESS_DOWNLOAD_PATH_TEMPLATE wrapped in quote
Browse files Browse the repository at this point in the history
  • Loading branch information
amoshydra committed Mar 19, 2022
1 parent a16645e commit 6c74734
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cli/__snapshots__/download_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,11 @@ https://download.cypress.io/desktop/0.20.2/darwin-x64/cypress.zip
exports['desktop url from template with escaped dollar sign'] = `
https://download.cypress.io/desktop/0.20.2/darwin-x64/cypress.zip
`

exports['desktop url from template wrapped in quote'] = `
https://download.cypress.io/desktop/0.20.2/darwin-x64/cypress.zip
`

exports['desktop url from template with escaped dollar sign wrapped in quote'] = `
https://download.cypress.io/desktop/0.20.2/darwin-x64/cypress.zip
`
2 changes: 1 addition & 1 deletion cli/lib/tasks/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const getCA = () => {
const prepend = (urlPath) => {
const endpoint = url.resolve(getBaseUrl(), urlPath)
const platform = os.platform()
const pathTemplate = util.getEnv('CYPRESS_DOWNLOAD_PATH_TEMPLATE')
const pathTemplate = util.getEnv('CYPRESS_DOWNLOAD_PATH_TEMPLATE', true)

return pathTemplate
? (
Expand Down
14 changes: 14 additions & 0 deletions cli/test/lib/tasks/download_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ describe('lib/tasks/download', function () {
snapshot('desktop url from template with escaped dollar sign', normalize(url))
})

it('returns custom url from template wrapped in quote', () => {
process.env.CYPRESS_DOWNLOAD_PATH_TEMPLATE = '"${endpoint}/${platform}-${arch}/cypress.zip"'
const url = download.getUrl('0.20.2')

snapshot('desktop url from template wrapped in quote', normalize(url))
})

it('returns custom url from template with escaped dollar sign wrapped in quote', () => {
process.env.CYPRESS_DOWNLOAD_PATH_TEMPLATE = '"\\${endpoint}/\\${platform}-\\${arch}/cypress.zip"'
const url = download.getUrl('0.20.2')

snapshot('desktop url from template with escaped dollar sign wrapped in quote', normalize(url))
})

it('returns input if it is already an https link', () => {
const url = 'https://somewhere.com'
const result = download.getUrl(url)
Expand Down

0 comments on commit 6c74734

Please sign in to comment.