-
Notifications
You must be signed in to change notification settings - Fork 0
/
shim.js
45 lines (40 loc) · 1.26 KB
/
shim.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
const childProcess = require('child_process')
const os = require('os')
const process = require('process')
function chooseBinary() {
const platform = os.platform()
const arch = os.arch()
if (platform === 'linux' && arch === 'x64') {
return `gha-docker-image-exists-linux-amd64`
}
if (platform === 'linux' && arch === 'arm64') {
return `gha-docker-image-exists-linux-arm64`
}
// if (platform === 'win32' && arch === 'x64') {
// return `gha-docker-image-exists-windows-amd64`
// }
// if (platform === 'win32' && arch === 'arm64') {
// return `gha-docker-image-exists-windows-arm64`
// }
if (platform === 'darwin' && arch === 'x64') {
return `gha-docker-image-exists-darwin-amd64`
}
if (platform === 'darwin' && arch === 'arm64') {
return `gha-docker-image-exists-darwin-arm64`
}
console.error(`Unsupported platform (${platform}) and architecture (${arch})`)
process.exit(1)
}
function main() {
const binary = chooseBinary()
const mainScript = `${__dirname}/bin/${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()
}