parent
945e912039
commit
96923a5a7f
61
dist/index.js
vendored
61
dist/index.js
vendored
|
@ -36,29 +36,50 @@ async function downloadZig (version) {
|
||||||
win32: 'zip'
|
win32: 'zip'
|
||||||
}[os.platform()]
|
}[os.platform()]
|
||||||
|
|
||||||
const index = await getJSON({ url: 'https://ziglang.org/download/index.json' })
|
if (version.includes('+')) {
|
||||||
|
// use exact commit hash
|
||||||
|
const addrhost = {
|
||||||
|
linux: 'linux-x86_64',
|
||||||
|
darwin: 'macos-x86_64',
|
||||||
|
win32: 'windows-x86_64'
|
||||||
|
}[os.platform()]
|
||||||
|
const downloadUrl = `https://ziglang.org/builds/zig-${addrhost}-${version}.${ext}`
|
||||||
|
const variantName = `zig-${addrhost}-${version}`
|
||||||
|
|
||||||
const availableVersions = Object.keys(index)
|
const downloadPath = await cache.downloadTool(downloadUrl)
|
||||||
const useVersion = semver.valid(version)
|
const zigPath = ext === 'zip'
|
||||||
? semver.maxSatisfying(availableVersions.filter((v) => semver.valid(v)), version)
|
? await cache.extractZip(downloadPath)
|
||||||
: null
|
: await cache.extractTar(downloadPath, undefined, 'x')
|
||||||
|
|
||||||
const meta = index[useVersion || version]
|
const binPath = path.join(zigPath, variantName)
|
||||||
if (!meta || !meta[host]) {
|
const cachePath = await cache.cacheDir(binPath, 'zig', variantName)
|
||||||
throw new Error(`Could not find version ${version} for platform ${host}`)
|
|
||||||
|
return cachePath
|
||||||
|
} else {
|
||||||
|
const index = await getJSON({ url: 'https://ziglang.org/download/index.json' })
|
||||||
|
|
||||||
|
const availableVersions = Object.keys(index)
|
||||||
|
const useVersion = semver.valid(version)
|
||||||
|
? semver.maxSatisfying(availableVersions.filter((v) => semver.valid(v)), version)
|
||||||
|
: null
|
||||||
|
|
||||||
|
const meta = index[useVersion || version]
|
||||||
|
if (!meta || !meta[host]) {
|
||||||
|
throw new Error(`Could not find version ${version} for platform ${host}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const variantName = path.basename(meta[host].tarball).replace(`.${ext}`, '')
|
||||||
|
|
||||||
|
const downloadPath = await cache.downloadTool(meta[host].tarball)
|
||||||
|
const zigPath = ext === 'zip'
|
||||||
|
? await cache.extractZip(downloadPath)
|
||||||
|
: await cache.extractTar(downloadPath, undefined, 'x')
|
||||||
|
|
||||||
|
const binPath = path.join(zigPath, variantName)
|
||||||
|
const cachePath = await cache.cacheDir(binPath, 'zig', variantName)
|
||||||
|
|
||||||
|
return cachePath
|
||||||
}
|
}
|
||||||
|
|
||||||
const variantName = path.basename(meta[host].tarball).replace(`.${ext}`, '')
|
|
||||||
|
|
||||||
const downloadPath = await cache.downloadTool(meta[host].tarball)
|
|
||||||
const zigPath = ext === 'zip'
|
|
||||||
? await cache.extractZip(downloadPath)
|
|
||||||
: await cache.extractTar(downloadPath, undefined, 'x')
|
|
||||||
|
|
||||||
const binPath = path.join(zigPath, variantName)
|
|
||||||
const cachePath = await cache.cacheDir(binPath, 'zig', variantName)
|
|
||||||
|
|
||||||
return cachePath
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
|
|
61
index.js
61
index.js
|
@ -29,29 +29,50 @@ async function downloadZig (version) {
|
||||||
win32: 'zip'
|
win32: 'zip'
|
||||||
}[os.platform()]
|
}[os.platform()]
|
||||||
|
|
||||||
const index = await getJSON({ url: 'https://ziglang.org/download/index.json' })
|
if (version.includes('+')) {
|
||||||
|
// use exact commit hash
|
||||||
|
const addrhost = {
|
||||||
|
linux: 'linux-x86_64',
|
||||||
|
darwin: 'macos-x86_64',
|
||||||
|
win32: 'windows-x86_64'
|
||||||
|
}[os.platform()]
|
||||||
|
const downloadUrl = `https://ziglang.org/builds/zig-${addrhost}-${version}.${ext}`
|
||||||
|
const variantName = `zig-${addrhost}-${version}`
|
||||||
|
|
||||||
const availableVersions = Object.keys(index)
|
const downloadPath = await cache.downloadTool(downloadUrl)
|
||||||
const useVersion = semver.valid(version)
|
const zigPath = ext === 'zip'
|
||||||
? semver.maxSatisfying(availableVersions.filter((v) => semver.valid(v)), version)
|
? await cache.extractZip(downloadPath)
|
||||||
: null
|
: await cache.extractTar(downloadPath, undefined, 'x')
|
||||||
|
|
||||||
const meta = index[useVersion || version]
|
const binPath = path.join(zigPath, variantName)
|
||||||
if (!meta || !meta[host]) {
|
const cachePath = await cache.cacheDir(binPath, 'zig', variantName)
|
||||||
throw new Error(`Could not find version ${version} for platform ${host}`)
|
|
||||||
|
return cachePath
|
||||||
|
} else {
|
||||||
|
const index = await getJSON({ url: 'https://ziglang.org/download/index.json' })
|
||||||
|
|
||||||
|
const availableVersions = Object.keys(index)
|
||||||
|
const useVersion = semver.valid(version)
|
||||||
|
? semver.maxSatisfying(availableVersions.filter((v) => semver.valid(v)), version)
|
||||||
|
: null
|
||||||
|
|
||||||
|
const meta = index[useVersion || version]
|
||||||
|
if (!meta || !meta[host]) {
|
||||||
|
throw new Error(`Could not find version ${version} for platform ${host}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const variantName = path.basename(meta[host].tarball).replace(`.${ext}`, '')
|
||||||
|
|
||||||
|
const downloadPath = await cache.downloadTool(meta[host].tarball)
|
||||||
|
const zigPath = ext === 'zip'
|
||||||
|
? await cache.extractZip(downloadPath)
|
||||||
|
: await cache.extractTar(downloadPath, undefined, 'x')
|
||||||
|
|
||||||
|
const binPath = path.join(zigPath, variantName)
|
||||||
|
const cachePath = await cache.cacheDir(binPath, 'zig', variantName)
|
||||||
|
|
||||||
|
return cachePath
|
||||||
}
|
}
|
||||||
|
|
||||||
const variantName = path.basename(meta[host].tarball).replace(`.${ext}`, '')
|
|
||||||
|
|
||||||
const downloadPath = await cache.downloadTool(meta[host].tarball)
|
|
||||||
const zigPath = ext === 'zip'
|
|
||||||
? await cache.extractZip(downloadPath)
|
|
||||||
: await cache.extractTar(downloadPath, undefined, 'x')
|
|
||||||
|
|
||||||
const binPath = path.join(zigPath, variantName)
|
|
||||||
const cachePath = await cache.cacheDir(binPath, 'zig', variantName)
|
|
||||||
|
|
||||||
return cachePath
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user