generated from actions/javascript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtester.js
40 lines (36 loc) · 880 Bytes
/
tester.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const os = require('os')
const axios = require('axios')
const path = require('path')
function getDownloadArch(arch) {
if (arch === 'x64') {
return 'amd64'
} else if (arch === 'x86') {
return 'amd64'
}
}
async function getDownloadUrl() {
let tag = "latest"
let response = null
try {
response = await axios({
url: "/~https://github.com/alexellis/arkade/releases/latest",
maxRedirects: 0,
method: "head",
timeout: 2500,
validateStatus: function (status) {
return status == 302
}
})
tag = response.headers.location;
} catch (error) {
throw error
}
// /~https://github.com/alexellis/arkade/releases/tag/0.9.17
let arch = getDownloadArch(os.arch())
return `${tag}/arkade-${arch}`
}
getDownloadUrl().then(d => {
console.log(d)
console.log(path.basename(d))
console.log(path.dirname(d))
})