@swestash/agent-lens 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1722,9 +1722,16 @@ function acquireLock(lockPath, staleMs = 6 * 60 * 60 * 1e3) {
1722
1722
  // ../core/dist/service.js
1723
1723
  import { spawnSync } from "child_process";
1724
1724
  import { mkdirSync as mkdirSync3, rmSync, writeFileSync as writeFileSync2 } from "fs";
1725
- import { homedir as homedir2, platform as platform3 } from "os";
1725
+ import { homedir as homedir2, platform as platform3, userInfo } from "os";
1726
1726
  import { join as join4 } from "path";
1727
1727
  var DEFAULT_HOURS = [9, 13, 17, 21];
1728
+ function currentUser() {
1729
+ try {
1730
+ return userInfo().username;
1731
+ } catch {
1732
+ return process.env.USER || process.env.LOGNAME || "";
1733
+ }
1734
+ }
1728
1735
  var SYSTEMD_COLLECTOR_TIMER = "agent-lens-collect.timer";
1729
1736
  var SYSTEMD_COLLECTOR_SERVICE = "agent-lens-collect.service";
1730
1737
  var SYSTEMD_SERVER_SERVICE = "agent-lens-server.service";
@@ -1894,8 +1901,9 @@ function linuxInstall(targets, node, cli2, hours) {
1894
1901
  console.log("agent-lens service: installed server daemon");
1895
1902
  sh("systemctl", ["--user", "status", SYSTEMD_SERVER_SERVICE, "--no-pager"]);
1896
1903
  }
1897
- if (have("loginctl") && !sh("loginctl", ["enable-linger", process.env.USER || ""], true)) {
1898
- console.log(`agent-lens: could not enable linger automatically; run: sudo loginctl enable-linger ${process.env.USER}`);
1904
+ const user = currentUser();
1905
+ if (user && have("loginctl") && !sh("loginctl", ["enable-linger", user], true)) {
1906
+ console.log(`agent-lens: could not enable linger automatically; run: sudo loginctl enable-linger ${user}`);
1899
1907
  }
1900
1908
  }
1901
1909
  function linuxUninstall(targets) {