forked from docker/scout-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (43 loc) · 1.39 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
const childProcess = require('child_process')
const os = require('os')
const path = require('path')
const process = require('process')
const BinaryName = "docker-scout-action"
function chooseBinary() {
const platform = os.platform()
const arch = os.arch()
if (platform === 'darwin' && arch === 'x64') {
return `${BinaryName}_darwin_amd64`
}
if (platform === 'darwin' && arch === 'arm64') {
return `${BinaryName}_darwin_arm64`
}
if (platform === 'linux' && arch === 'x64') {
return `${BinaryName}_linux_amd64`
}
if (platform === 'linux' && arch === 'arm64') {
return `${BinaryName}_linux_arm64`
}
if (platform === 'win32' && arch === 'x64') {
return `${BinaryName}_windows_amd64.exe`
}
if (platform === 'win32' && arch === 'arm64') {
return `${BinaryName}_windows_arm64.exe`
}
console.error(`Unsupported platform (${platform}) and architecture (${arch})`)
process.exit(1)
return `${BinaryName}_${platform}_${arch}`
}
function main() {
const binary = chooseBinary()
const mainScript = path.join(__dirname, "dist", binary);
const spawnSyncReturns = childProcess.spawnSync(mainScript, { stdio: 'inherit' })
const status = spawnSyncReturns.status
if (typeof status === 'number') {
process.exit(status)
}
process.exit(1)
}
if (require.main === module) {
main()
}