in src/server/install.ts [125:163]
private async downloadCoursier(): Promise<string | undefined> {
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'coursier-'))
const coursierPath = path.join(tempDir, 'coursier')
let coursierUrl: string
coursierUrl =
os.platform() === 'darwin'
? os.arch() === 'arm64'
? COURSIER_URL_APPLE_SILICON
: COURSIER_URL_APPLE_INTEL
: COURSIER_URL_DEFAULT
this.outputChannel.appendLine(`Downloading Coursier from ${coursierUrl}`)
try {
const response = await axios.default.get(coursierUrl, {
responseType: 'arraybuffer',
})
let fileData = response.data
// Decompress if downloading a gzipped file
if (coursierUrl.endsWith('.gz')) {
this.outputChannel.appendLine('Using gzipped Coursier')
fileData = await Utils.gunzip(fileData)
}
await fs.writeFile(coursierPath, fileData)
await fs.chmod(coursierPath, 0o755)
} catch (e) {
this.outputChannel.appendLine(`Failed to download Coursier: ${e}`)
return undefined
}
this.outputChannel.appendLine(
`Coursier temporarily installed at ${coursierPath}`
)
return coursierPath
}