@walldock/agent 0.2.5 → 0.2.6
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/main.js +0 -5
- package/dist/startup.js +21 -17
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -102,11 +102,6 @@ async function main() {
|
|
|
102
102
|
}
|
|
103
103
|
// --register-startup: (re-)register the startup entry without going through pairing
|
|
104
104
|
if (args.includes('--register-startup')) {
|
|
105
|
-
const globalBin = await (0, startup_1.getGlobalBin)();
|
|
106
|
-
if (!globalBin) {
|
|
107
|
-
console.error('walldock-agent is not globally installed. Run: npm install -g @walldock/agent');
|
|
108
|
-
process.exit(1);
|
|
109
|
-
}
|
|
110
105
|
try {
|
|
111
106
|
await (0, startup_1.registerStartup)();
|
|
112
107
|
console.log(`✓ Registered for startup (${(0, startup_1.startupDescription)()})`);
|
package/dist/startup.js
CHANGED
|
@@ -45,28 +45,32 @@ const node_util_1 = require("node:util");
|
|
|
45
45
|
const exec = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
46
46
|
// ─── Global bin resolution ────────────────────────────────────────────────────
|
|
47
47
|
async function resolveGlobalBin() {
|
|
48
|
-
let prefix;
|
|
49
|
-
try {
|
|
50
|
-
const npmBin = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
51
|
-
const { stdout } = await exec(npmBin, ['prefix', '-g']);
|
|
52
|
-
prefix = stdout.trim();
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
throw new Error('Could not determine npm global prefix.\n' +
|
|
56
|
-
'Make sure npm is installed and run: npm install -g @walldock/agent');
|
|
57
|
-
}
|
|
58
48
|
const binName = process.platform === 'win32' ? 'walldock-agent.cmd' : 'walldock-agent';
|
|
59
|
-
|
|
60
|
-
? path.join(prefix, binName)
|
|
61
|
-
: path.join(prefix, 'bin', binName);
|
|
49
|
+
// First try: derive path from npm global prefix
|
|
62
50
|
try {
|
|
51
|
+
const npmBin = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
52
|
+
const { stdout } = await exec(npmBin, ['prefix', '-g'], { encoding: 'utf8' });
|
|
53
|
+
const prefix = stdout.trim();
|
|
54
|
+
const binPath = process.platform === 'win32'
|
|
55
|
+
? path.join(prefix, binName)
|
|
56
|
+
: path.join(prefix, 'bin', binName);
|
|
63
57
|
await fs.access(binPath);
|
|
58
|
+
return binPath;
|
|
64
59
|
}
|
|
65
|
-
catch {
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
catch { /* fall through to PATH lookup */ }
|
|
61
|
+
// Second try: search PATH (handles nvm-windows, custom prefixes, etc.)
|
|
62
|
+
try {
|
|
63
|
+
const whereCmd = process.platform === 'win32' ? 'where' : 'which';
|
|
64
|
+
const { stdout } = await exec(whereCmd, [binName], { encoding: 'utf8' });
|
|
65
|
+
const found = stdout.trim().split('\n')[0]?.trim();
|
|
66
|
+
if (found) {
|
|
67
|
+
await fs.access(found);
|
|
68
|
+
return found;
|
|
69
|
+
}
|
|
68
70
|
}
|
|
69
|
-
|
|
71
|
+
catch { /* fall through */ }
|
|
72
|
+
throw new Error(`walldock-agent is not globally installed.\n` +
|
|
73
|
+
'Run: npm install -g @walldock/agent');
|
|
70
74
|
}
|
|
71
75
|
// ─── macOS ───────────────────────────────────────────────────────────────────
|
|
72
76
|
const LAUNCH_AGENTS_DIR = path.join(os.homedir(), 'Library', 'LaunchAgents');
|