@ctrl-spc/cli 1.1.6 → 1.1.7
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.
- package/dist/launchd.js +10 -6
- package/package.json +1 -1
package/dist/launchd.js
CHANGED
|
@@ -60,17 +60,21 @@ export function buildPlist(nodePath, scriptPath, home = homedir(), daemonPath =
|
|
|
60
60
|
</dict>
|
|
61
61
|
</plist>`;
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
const home = homedir();
|
|
63
|
+
function writeDaemonPlist(home = homedir()) {
|
|
65
64
|
const launchAgentsDir = join(home, 'Library', 'LaunchAgents');
|
|
66
65
|
const plistPath = getPlistPath(home);
|
|
66
|
+
ensureStateDir(home);
|
|
67
|
+
mkdirSync(launchAgentsDir, { recursive: true });
|
|
68
|
+
writeFileSync(plistPath, buildPlist(process.execPath, resolveBinPath(), home), 'utf8');
|
|
69
|
+
return plistPath;
|
|
70
|
+
}
|
|
71
|
+
export async function installDaemon() {
|
|
72
|
+
const home = homedir();
|
|
67
73
|
const uid = process.getuid?.();
|
|
68
74
|
if (uid === undefined) {
|
|
69
75
|
throw new Error(INSTALL_FAILED_MESSAGE);
|
|
70
76
|
}
|
|
71
|
-
|
|
72
|
-
mkdirSync(launchAgentsDir, { recursive: true });
|
|
73
|
-
writeFileSync(plistPath, buildPlist(process.execPath, resolveBinPath(), home), 'utf8');
|
|
77
|
+
const plistPath = writeDaemonPlist(home);
|
|
74
78
|
const domain = `gui/${uid}`;
|
|
75
79
|
try {
|
|
76
80
|
try {
|
|
@@ -113,7 +117,7 @@ export async function restartDaemon(home = homedir(), exec = defaultExec) {
|
|
|
113
117
|
const uid = process.getuid?.();
|
|
114
118
|
if (uid === undefined)
|
|
115
119
|
throw new Error(RESTART_FAILED_MESSAGE);
|
|
116
|
-
const plistPath =
|
|
120
|
+
const plistPath = writeDaemonPlist(home);
|
|
117
121
|
try {
|
|
118
122
|
exec('launchctl', kickstartArgs(uid));
|
|
119
123
|
}
|