Skip to content

Commit

Permalink
Download dmg automatically for darwin (#82)
Browse files Browse the repository at this point in the history
* Try to show dmg

* Remove leftover isUpdate
  • Loading branch information
RobbieTheWagner authored Feb 6, 2020
1 parent 2d00a4a commit 1a2623a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const querystring = require('querystring');

// Packages
const { send } = require('micro')
const { valid, compare } = require('semver')
Expand Down Expand Up @@ -35,10 +37,15 @@ module.exports = ({ cache, config }) => {

exports.download = async (req, res) => {
const userAgent = parse(req.headers['user-agent'])
const queryParams = req.url.split('?')[1]
const params = queryParams ? querystring.parse(queryParams) : null
const isUpdate = params && params.update
let platform

if (userAgent.isMac) {
if (userAgent.isMac && isUpdate) {
platform = 'darwin'
} else if (userAgent.isMac && !isUpdate) {
platform = 'dmg'
} else if (userAgent.isWindows) {
platform = 'exe'
}
Expand Down Expand Up @@ -145,7 +152,7 @@ module.exports = ({ cache, config }) => {
notes,
pub_date,
url: shouldProxyPrivateDownload
? `${url}/download/${platformName}`
? `${url}/download/${platformName}?update=true`
: latest.platforms[platform].url
})

Expand Down Expand Up @@ -180,14 +187,6 @@ module.exports = ({ cache, config }) => {
exports.overview = async (req, res) => {
const latest = await loadCache()

// Filter out special platforms that should not
// be shown on the overview page
Object.keys(latest.platforms).forEach(platform => {
if (platform === 'dmg') {
delete latest.platforms[platform]
}
})

try {
const render = await prepareView()

Expand Down

1 comment on commit 1a2623a

@vercel
Copy link

@vercel vercel bot commented on 1a2623a Feb 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.