UNPKG

gitduck

Version:

Share your terminal on a Duckly video call

59 lines (49 loc) 1.31 kB
#!/usr/bin/env node // @ts-check 'use strict' const path = require('path') const { spawnSync } = require('child_process') const exe_ext = process.platform === 'win32' ? '.exe' : '' let platform switch (process.platform) { case 'darwin': platform = 'macos' break case 'win32': platform = 'win' break default: platform = 'linux' break } let arch switch (process.arch) { case 'ia32': arch = 'x86' if (platform !== 'win') throw new Error(`Unsupported processor architeture ${process.arch}`) break case 'x64': arch = 'x64' break case 'arm64': if (process.platform === 'darwin') { // Returns the x86_64 version for the Apple M1 chip so Rosetta 2 takes place of it for now arch = 'x64' break } throw new Error(`Unsupported processor architeture ${process.arch}`) default: throw new Error(`Unsupported processor architeture ${process.arch}`) } const duckly = path.resolve(__dirname, `duckly-shell-${platform}-${arch}${exe_ext}`) // remove first two args, the node binary and this script itself const args = process.argv.slice(2) const { error, signal, status } = spawnSync(duckly, args, { stdio: 'inherit', }) if (error) throw error if (signal) { process.kill(process.pid, signal) } else { process.exit(status) }