export default function () {
  if (typeof window.nodeRequire == "undefined") {
    console.log("nodeRequire failed");
    return {};
  }

  const os: typeof import("os") = window.nodeRequire("os");
  const infos: Record<string, string | number> = {};
  infos.arch = os.arch();
  infos.platform = os.platform();
  infos.release = os.release();
  infos.type = os.type();
  infos.hostname = os.hostname();
  infos.totalmem = os.totalmem() / 1024 / 1024 / 1024;
  infos.freemem = os.freemem() / 1024 / 1024 / 1024;

  infos.cpus = JSON.stringify(os.cpus());
  infos.networkInterfaces = JSON.stringify(os.networkInterfaces());
  infos.userInfo = JSON.stringify(os.userInfo());
  infos.loadavg = JSON.stringify(os.loadavg());
  return infos;
}
