Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download dmg automatically for darwin #82

Merged
merged 2 commits into from
Feb 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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