@ctrl-spc/cli 1.1.7 → 1.1.9

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.
Files changed (2) hide show
  1. package/dist/launchd.js +15 -2
  2. package/package.json +1 -1
package/dist/launchd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { execFileSync } from 'node:child_process';
2
2
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
- import { join } from 'node:path';
4
+ import { basename, join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { ensureStateDir, getStatePaths } from './session.js';
7
7
  export const PLIST_LABEL = 'com.ctrl-spc.daemon';
@@ -32,6 +32,7 @@ export function buildDaemonPath(home = homedir(), envPath = process.env.PATH ??
32
32
  }
33
33
  export function buildPlist(nodePath, scriptPath, home = homedir(), daemonPath = buildDaemonPath(home)) {
34
34
  const { daemonLogPath } = getStatePaths(home);
35
+ const user = process.env.USER || process.env.LOGNAME || basename(home);
35
36
  return `<?xml version="1.0" encoding="UTF-8"?>
36
37
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
37
38
  <plist version="1.0">
@@ -50,8 +51,14 @@ export function buildPlist(nodePath, scriptPath, home = homedir(), daemonPath =
50
51
  <true/>
51
52
  <key>EnvironmentVariables</key>
52
53
  <dict>
54
+ <key>HOME</key>
55
+ <string>${escapeXml(home)}</string>
56
+ <key>LOGNAME</key>
57
+ <string>${escapeXml(user)}</string>
53
58
  <key>PATH</key>
54
59
  <string>${escapeXml(daemonPath)}</string>
60
+ <key>USER</key>
61
+ <string>${escapeXml(user)}</string>
55
62
  </dict>
56
63
  <key>StandardErrorPath</key>
57
64
  <string>${escapeXml(daemonLogPath)}</string>
@@ -119,11 +126,17 @@ export async function restartDaemon(home = homedir(), exec = defaultExec) {
119
126
  throw new Error(RESTART_FAILED_MESSAGE);
120
127
  const plistPath = writeDaemonPlist(home);
121
128
  try {
129
+ exec('launchctl', bootoutArgs(uid, plistPath));
130
+ }
131
+ catch {
132
+ // Already stopped or not loaded; bootstrap below covers both cases.
133
+ }
134
+ try {
135
+ exec('launchctl', bootstrapArgs(uid, plistPath));
122
136
  exec('launchctl', kickstartArgs(uid));
123
137
  }
124
138
  catch {
125
139
  try {
126
- exec('launchctl', bootstrapArgs(uid, plistPath));
127
140
  exec('launchctl', kickstartArgs(uid));
128
141
  }
129
142
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl-spc/cli",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "Control Space CLI - machine setup and background daemon",
5
5
  "type": "module",
6
6
  "files": [