qsu
Version:
qsu is a utility library that contains useful and frequently used functions. Start with your preferred language and the modern development environment.
1 lines • 681 B
JavaScript
import{platform as r}from"os";import{runCommand as e}from"./runCommand.js";export async function getMachineId(){const i=r();let t;t="win32"===i?"for /f \"tokens=3 delims= \" %i in ('REG QUERY HKLM\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid ^| findstr MachineGuid') do @echo %i":"darwin"===i?"ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/' | cut -d '\"' -f4":"freebsd"===i?"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid":"(cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname) | head -n 1 || :";try{const r=await e(t);if(r)return r}catch(r){if(r instanceof Error)throw new Error(r?.message)}throw new Error("Failed to get machine id")}