Skip to content

Commit 1a2623a

Browse files
Download dmg automatically for darwin (#82)
* Try to show dmg * Remove leftover isUpdate
1 parent 2d00a4a commit 1a2623a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/routes.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const querystring = require('querystring');
2+
13
// Packages
24
const { send } = require('micro')
35
const { valid, compare } = require('semver')
@@ -35,10 +37,15 @@ module.exports = ({ cache, config }) => {
3537

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

40-
if (userAgent.isMac) {
45+
if (userAgent.isMac && isUpdate) {
4146
platform = 'darwin'
47+
} else if (userAgent.isMac && !isUpdate) {
48+
platform = 'dmg'
4249
} else if (userAgent.isWindows) {
4350
platform = 'exe'
4451
}
@@ -145,7 +152,7 @@ module.exports = ({ cache, config }) => {
145152
notes,
146153
pub_date,
147154
url: shouldProxyPrivateDownload
148-
? `${url}/download/${platformName}`
155+
? `${url}/download/${platformName}?update=true`
149156
: latest.platforms[platform].url
150157
})
151158

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

183-
// Filter out special platforms that should not
184-
// be shown on the overview page
185-
Object.keys(latest.platforms).forEach(platform => {
186-
if (platform === 'dmg') {
187-
delete latest.platforms[platform]
188-
}
189-
})
190-
191190
try {
192191
const render = await prepareView()
193192

0 commit comments

Comments
 (0)