UNPKG

@open-audio-stack/core

Version:
32 lines (31 loc) 1.01 kB
import { exec } from 'child_process'; import { SystemType } from '../types/SystemType.js'; import { Architecture } from '../types/Architecture.js'; export function getArchitecture() { if (process.arch === 'arm') return Architecture.Arm32; if (process.arch === 'arm64') return Architecture.Arm64; if (process.arch === 'ia32') return Architecture.X32; return Architecture.X64; } export function getSystem() { if (process.platform === 'win32') return SystemType.Win; else if (process.platform === 'darwin') return SystemType.Mac; return SystemType.Linux; } export function isTests() { const jest = process.env.JEST_WORKER_ID !== undefined; const vitest = process.env.VITEST_WORKER_ID !== undefined; return jest || vitest; } export function commandExists(cmd) { return new Promise(resolve => { exec(`command -v ${cmd}`, (error, stdout) => { resolve(Boolean(stdout.trim()) && !error); }); }); }