Add JS shim
This commit is contained in:
parent
6eb5d3c3c9
commit
1b658de968
1 changed files with 39 additions and 0 deletions
39
invoke-binary.js
Normal file
39
invoke-binary.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
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 `linux-amd64`
|
||||
}
|
||||
if (platform === 'linux' && arch === 'arm64') {
|
||||
return `linux-arm64`
|
||||
}
|
||||
if (platform === 'windows' && arch === 'x64') {
|
||||
return `windows-amd64.exe`
|
||||
}
|
||||
if (platform === 'windows' && arch === 'arm64') {
|
||||
return `windows-arm64.exe`
|
||||
}
|
||||
|
||||
console.error(`Unsupported platform (${platform}) and architecture (${arch})`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
function main() {
|
||||
const binary = chooseBinary()
|
||||
const mainScript = `${__dirname}/${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()
|
||||
}
|
Reference in a new issue