@kud/foxhop-cli 1.1.2 → 1.1.3
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/cli.js +28 -4
- package/dist/host-cli.js +20 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import { defineCommand, runMain } from "citty";
|
|
5
5
|
import { spawn } from "child_process";
|
|
6
|
-
import { existsSync as existsSync3 } from "fs";
|
|
6
|
+
import { existsSync as existsSync3, unlinkSync } from "fs";
|
|
7
7
|
|
|
8
8
|
// src/config.ts
|
|
9
9
|
import { mkdirSync, readFileSync, writeFileSync, existsSync } from "fs";
|
|
@@ -197,11 +197,19 @@ var install = () => {
|
|
|
197
197
|
const distDir = dirname(fileURLToPath(import.meta.url));
|
|
198
198
|
const hostEntry = join3(distDir, "host-cli.js");
|
|
199
199
|
chmodSync(hostEntry, 493);
|
|
200
|
+
const wrapperPath = join3(distDir, "host-launch.sh");
|
|
201
|
+
writeFileSync2(
|
|
202
|
+
wrapperPath,
|
|
203
|
+
`#!/bin/sh
|
|
204
|
+
exec ${JSON.stringify(process.execPath)} ${JSON.stringify(hostEntry)} "$@"
|
|
205
|
+
`
|
|
206
|
+
);
|
|
207
|
+
chmodSync(wrapperPath, 493);
|
|
200
208
|
mkdirSync2(MANIFEST_DIR, { recursive: true });
|
|
201
209
|
const manifest = {
|
|
202
210
|
name: HOST_NAME,
|
|
203
211
|
description: "foxhop native messaging host",
|
|
204
|
-
path:
|
|
212
|
+
path: wrapperPath,
|
|
205
213
|
type: "stdio",
|
|
206
214
|
allowed_extensions: [EXTENSION_ID]
|
|
207
215
|
};
|
|
@@ -209,7 +217,8 @@ var install = () => {
|
|
|
209
217
|
process.stdout.write(
|
|
210
218
|
`foxhop: installed native host manifest
|
|
211
219
|
manifest \u2192 ${MANIFEST_PATH}
|
|
212
|
-
host \u2192 ${
|
|
220
|
+
host \u2192 ${wrapperPath}
|
|
221
|
+
node \u2192 ${process.execPath}
|
|
213
222
|
`
|
|
214
223
|
);
|
|
215
224
|
};
|
|
@@ -366,7 +375,22 @@ var focus = defineCommand({
|
|
|
366
375
|
if (ack?.ok && ack.action !== "not-found") foreground();
|
|
367
376
|
else
|
|
368
377
|
console.error(fail(ack?.error ?? "no matching tab and no url to open"));
|
|
369
|
-
} catch {
|
|
378
|
+
} catch (error) {
|
|
379
|
+
const code = error?.code;
|
|
380
|
+
if (code === "ECONNREFUSED" || code === "ENOENT") {
|
|
381
|
+
if (existsSync3(SOCKET_PATH)) {
|
|
382
|
+
try {
|
|
383
|
+
unlinkSync(SOCKET_PATH);
|
|
384
|
+
} catch {
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
console.error(
|
|
388
|
+
fail(
|
|
389
|
+
"foxhop host not running. Run `foxhop install`, then restart Firefox (or reload the extension)."
|
|
390
|
+
)
|
|
391
|
+
);
|
|
392
|
+
process.exit(1);
|
|
393
|
+
}
|
|
370
394
|
if ("url" in request && request.url) {
|
|
371
395
|
openUrl(request.url);
|
|
372
396
|
} else {
|
package/dist/host-cli.js
CHANGED
|
@@ -58,13 +58,18 @@ var runHost = () => {
|
|
|
58
58
|
resolve(ack);
|
|
59
59
|
})
|
|
60
60
|
);
|
|
61
|
-
|
|
62
|
-
if (existsSync(SOCKET_PATH)) {
|
|
61
|
+
const cleanup = () => {
|
|
63
62
|
try {
|
|
64
|
-
unlinkSync(SOCKET_PATH);
|
|
63
|
+
if (existsSync(SOCKET_PATH)) unlinkSync(SOCKET_PATH);
|
|
65
64
|
} catch {
|
|
66
65
|
}
|
|
67
|
-
}
|
|
66
|
+
};
|
|
67
|
+
process.stdin.on("end", () => {
|
|
68
|
+
cleanup();
|
|
69
|
+
process.exit(0);
|
|
70
|
+
});
|
|
71
|
+
process.on("exit", cleanup);
|
|
72
|
+
cleanup();
|
|
68
73
|
const server = net.createServer((socket) => {
|
|
69
74
|
socket.setEncoding("utf8");
|
|
70
75
|
let raw = "";
|
|
@@ -107,11 +112,19 @@ var install = () => {
|
|
|
107
112
|
const distDir = dirname(fileURLToPath(import.meta.url));
|
|
108
113
|
const hostEntry = join2(distDir, "host-cli.js");
|
|
109
114
|
chmodSync(hostEntry, 493);
|
|
115
|
+
const wrapperPath = join2(distDir, "host-launch.sh");
|
|
116
|
+
writeFileSync(
|
|
117
|
+
wrapperPath,
|
|
118
|
+
`#!/bin/sh
|
|
119
|
+
exec ${JSON.stringify(process.execPath)} ${JSON.stringify(hostEntry)} "$@"
|
|
120
|
+
`
|
|
121
|
+
);
|
|
122
|
+
chmodSync(wrapperPath, 493);
|
|
110
123
|
mkdirSync(MANIFEST_DIR, { recursive: true });
|
|
111
124
|
const manifest = {
|
|
112
125
|
name: HOST_NAME,
|
|
113
126
|
description: "foxhop native messaging host",
|
|
114
|
-
path:
|
|
127
|
+
path: wrapperPath,
|
|
115
128
|
type: "stdio",
|
|
116
129
|
allowed_extensions: [EXTENSION_ID]
|
|
117
130
|
};
|
|
@@ -119,7 +132,8 @@ var install = () => {
|
|
|
119
132
|
process.stdout.write(
|
|
120
133
|
`foxhop: installed native host manifest
|
|
121
134
|
manifest \u2192 ${MANIFEST_PATH}
|
|
122
|
-
host \u2192 ${
|
|
135
|
+
host \u2192 ${wrapperPath}
|
|
136
|
+
node \u2192 ${process.execPath}
|
|
123
137
|
`
|
|
124
138
|
);
|
|
125
139
|
};
|