remote-term 0.1.3 → 0.1.5
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/bin/remote-term +11 -4
- package/install.js +19 -1
- package/package.json +1 -1
package/bin/remote-term
CHANGED
|
@@ -7,16 +7,23 @@ const fs = require("fs");
|
|
|
7
7
|
const isWindows = process.platform === "win32";
|
|
8
8
|
const binaryName = isWindows ? "remote-term-binary.exe" : "remote-term-binary";
|
|
9
9
|
const binaryPath = path.join(__dirname, binaryName);
|
|
10
|
+
const args = process.argv.slice(2);
|
|
10
11
|
|
|
11
12
|
if (!fs.existsSync(binaryPath)) {
|
|
12
|
-
|
|
13
|
+
// Show version from package.json even if binary is missing
|
|
14
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
15
|
+
const pkg = require("../package.json");
|
|
16
|
+
console.log(`remote-term v${pkg.version} (binary not installed)`);
|
|
17
|
+
console.error("Binary missing. Reinstall: npm i -g remote-term");
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
console.error("Error: remote-term binary not found.");
|
|
21
|
+
console.error("Try reinstalling: npm i -g remote-term");
|
|
13
22
|
process.exit(1);
|
|
14
23
|
}
|
|
15
24
|
|
|
16
25
|
try {
|
|
17
|
-
|
|
18
|
-
stdio: "inherit",
|
|
19
|
-
});
|
|
26
|
+
execFileSync(binaryPath, args, { stdio: "inherit" });
|
|
20
27
|
} catch (err) {
|
|
21
28
|
process.exit(err.status || 1);
|
|
22
29
|
}
|
package/install.js
CHANGED
|
@@ -63,10 +63,27 @@ async function main() {
|
|
|
63
63
|
const outputName = isWindows ? "remote-term-binary.exe" : "remote-term-binary";
|
|
64
64
|
const outputPath = path.join(binDir, outputName);
|
|
65
65
|
|
|
66
|
+
// Remove old binary before downloading new one (clean upgrade)
|
|
67
|
+
try {
|
|
68
|
+
fs.unlinkSync(outputPath);
|
|
69
|
+
} catch (_) {
|
|
70
|
+
// Ignore if doesn't exist
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
console.log(`Downloading remote-term v${VERSION} for ${process.platform}-${process.arch}...`);
|
|
67
74
|
|
|
68
75
|
try {
|
|
69
76
|
const data = await download(url);
|
|
77
|
+
|
|
78
|
+
// Validate binary is not empty or an HTML error page
|
|
79
|
+
if (data.length < 1024) {
|
|
80
|
+
throw new Error(`Downloaded file too small (${data.length} bytes) — likely not a valid binary`);
|
|
81
|
+
}
|
|
82
|
+
const header = data.slice(0, 16).toString("utf8");
|
|
83
|
+
if (header.includes("<html") || header.includes("<!DOCTYPE")) {
|
|
84
|
+
throw new Error("Downloaded an HTML page instead of a binary — release may not exist yet");
|
|
85
|
+
}
|
|
86
|
+
|
|
70
87
|
fs.mkdirSync(binDir, { recursive: true });
|
|
71
88
|
fs.writeFileSync(outputPath, data);
|
|
72
89
|
|
|
@@ -76,7 +93,8 @@ async function main() {
|
|
|
76
93
|
|
|
77
94
|
console.log(`Installed remote-term v${VERSION} to ${outputPath}`);
|
|
78
95
|
} catch (err) {
|
|
79
|
-
console.error(
|
|
96
|
+
console.error(`\n*** Failed to install remote-term v${VERSION} ***`);
|
|
97
|
+
console.error(`Error: ${err.message}`);
|
|
80
98
|
console.error(`\nManual install:`);
|
|
81
99
|
console.error(` Download: ${url}`);
|
|
82
100
|
console.error(` Place in: ${binDir}`);
|
package/package.json
CHANGED