in src/utilities.ts [59:123]
throw Error(
util.format('%s exited with result code %s', toolPath, result)
)
}
}
return execResult
}
export async function setCachedToolPath(toolName: string, version: string) {
let cachedToolpath = ''
let downloadPath = ''
const downloadUrl = getDownloadUrl(toolName, version)
try {
downloadPath = await toolCache.downloadTool(downloadUrl)
} catch (exeption) {
throw new Error(
`Failed to download the ${toolName} from ${downloadUrl}. Error: ${exeption}`
)
}
if (toolName == 'helm') {
fs.chmodSync(downloadPath, '777')
const unzipedHelmPath = await toolCache.extractZip(downloadPath)
cachedToolpath = await toolCache.cacheDir(
unzipedHelmPath,
toolName,
version
)
} else {
cachedToolpath = await toolCache.cacheFile(
downloadPath,
toolName + getExecutableExtension(),
toolName,
version
)
}
return cachedToolpath
}
export function getDownloadUrl(toolName: string, version: string): string {
const system = os.type()
const systemAndArch = system == 'Linux' ? `${system}_${os.arch()}` : system
if (
!downloadLinks[systemAndArch] ||
!downloadLinks[systemAndArch][toolName]
) {
throw Error('Unknown OS or render engine type')
}
return util.format(downloadLinks[systemAndArch][toolName], version)
}
export async function getStableVerison(toolName: string) {
if (!stableVersionUrls[toolName]) {
throw Error('Unable to download. Unknown tool name')
}
return toolCache.downloadTool(stableVersionUrls[toolName]).then(
(downloadPath) => {
let response = fs.readFileSync(downloadPath, 'utf8').toString().trim()
if (toolName == 'helm') {