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 • 446 B
JavaScript
import{hostname as n,platform as r}from"os";import{runCommand as t}from"./runCommand.js";export async function getHostname(){const e=r();let o;if("win32"===e)return process.env.COMPUTERNAME||n()||"Unknown";if("darwin"===e)o="scutil --get ComputerName";else{if("linux"!==e&&"freebsd"!==e)return n()||"Unknown";o="hostnamectl hostname"}try{const n=await t(o);if(n)return n}catch(n){if(n instanceof Error)throw new Error(n?.message)}return"Unknown"}