fix: use hardcoded version for asset url

This commit is contained in:
calebboyd
2019-04-01 16:38:06 -05:00
parent d73325ba35
commit b3c2d2e764
3 changed files with 23 additions and 32 deletions
+21 -30
View File
@@ -3,7 +3,6 @@ import { pathExistsAsync } from '../util'
import { LogStep } from '../logger'
import { IncomingMessage } from 'http'
import { NexeCompiler, NexeError } from '../compiler'
import { getLatestGitRelease } from '../releases'
import { dirname } from 'path'
function fetchNodeSourceAsync(dest: string, url: string, step: LogStep, options = {}) {
@@ -24,37 +23,29 @@ function fetchNodeSourceAsync(dest: string, url: string, step: LogStep, options
}
async function fetchPrebuiltBinary(compiler: NexeCompiler, step: any) {
let downloadOptions = compiler.options.downloadOptions
const target = compiler.target
const target = compiler.target,
asset = 'https://github.com/nexe/nexe/releases/download/v3.0.0/' + target.toString(),
filename = compiler.getNodeExecutableLocation(target)
if (compiler.options.ghToken) {
downloadOptions = Object.assign({}, downloadOptions)
downloadOptions.headers = Object.assign({}, downloadOptions.headers, {
Authorization: 'token ' + compiler.options.ghToken
})
try {
await download(asset, dirname(filename), compiler.options.downloadOptions).on(
'response',
(res: IncomingMessage) => {
const total = +res.headers['content-length']!
let current = 0
res.on('data', data => {
current += data.length
step!.modify(`Downloading...${((current / total) * 100).toFixed()}%`)
})
}
)
} catch (e) {
if (e.statusCode === 404) {
throw new NexeError(`${asset} not available, create it using the --build flag`)
} else {
throw new NexeError('Error downloading prebuilt binary: ' + e)
}
}
const githubRelease = await getLatestGitRelease(downloadOptions)
const assetName = target.toString()
const asset = githubRelease.assets.find(x => x.name === assetName)
if (!asset) {
throw new NexeError(`${assetName} not available, create it using the --build flag`)
}
const filename = compiler.getNodeExecutableLocation(target)
await download(
asset.browser_download_url,
dirname(filename),
compiler.options.downloadOptions
).on('response', (res: IncomingMessage) => {
const total = +res.headers['content-length']!
let current = 0
res.on('data', data => {
current += data.length
step!.modify(`Downloading...${((current / total) * 100).toFixed()}%`)
})
})
}
/**