termbeam 1.0.1 → 1.0.2

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/package.json +1 -1
  2. package/src/cli.js +33 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "termbeam",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Beam your terminal to any device — mobile-optimized web terminal with multi-session support",
5
5
  "main": "src/server.js",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -76,7 +76,10 @@ function getWindowsAncestors(startPid, maxDepth = 4) {
76
76
  if (cols.length <= Math.max(nameIdx, pidIdx, ppidIdx)) continue;
77
77
  const pid = parseInt(cols[pidIdx], 10);
78
78
  if (Number.isFinite(pid)) {
79
- processes.set(pid, { name: cols[nameIdx].trim().toLowerCase(), ppid: parseInt(cols[ppidIdx], 10) });
79
+ processes.set(pid, {
80
+ name: cols[nameIdx].trim().toLowerCase(),
81
+ ppid: parseInt(cols[ppidIdx], 10),
82
+ });
80
83
  }
81
84
  }
82
85
 
@@ -137,8 +140,14 @@ function getDefaultShell() {
137
140
  const comm = result.trim();
138
141
  if (comm) {
139
142
  const shell = comm.startsWith('-') ? comm.slice(1) : comm;
140
- log.debug(`Detected parent shell: ${shell}`);
141
- return shell;
143
+ log.debug(`Detected parent process: ${shell}`);
144
+ // Validate it looks like a real shell (single token, no spaces)
145
+ // When run via npx, comm can be "npm exec ..." which is not a shell
146
+ if (!shell.includes(' ') && !shell.startsWith('npm') && !shell.startsWith('node')) {
147
+ log.debug(`Using detected shell: ${shell}`);
148
+ return shell;
149
+ }
150
+ log.debug(`Parent process "${shell}" is not a shell, falling back`);
142
151
  }
143
152
  } catch (err) {
144
153
  log.debug(`Could not detect parent shell: ${err.message}`);
@@ -157,10 +166,16 @@ function parseArgs() {
157
166
  // Resolve log level early (env + args) so shell detection logs are visible
158
167
  let logLevel = process.env.TERMBEAM_LOG_LEVEL || 'info';
159
168
  for (const arg of process.argv.slice(2)) {
160
- if (arg.startsWith('--log-level=')) { logLevel = arg.split('=')[1]; break; }
169
+ if (arg.startsWith('--log-level=')) {
170
+ logLevel = arg.split('=')[1];
171
+ break;
172
+ }
161
173
  }
162
174
  for (let i = 2; i < process.argv.length; i++) {
163
- if (process.argv[i] === '--log-level' && process.argv[i + 1]) { logLevel = process.argv[i + 1]; break; }
175
+ if (process.argv[i] === '--log-level' && process.argv[i + 1]) {
176
+ logLevel = process.argv[i + 1];
177
+ break;
178
+ }
164
179
  }
165
180
  log.setLevel(logLevel);
166
181
 
@@ -227,7 +242,19 @@ function parseArgs() {
227
242
  const { getVersion } = require('./version');
228
243
  const version = getVersion();
229
244
 
230
- return { port, host, password, useTunnel, persistedTunnel, shell, shellArgs, cwd, defaultShell, version, logLevel };
245
+ return {
246
+ port,
247
+ host,
248
+ password,
249
+ useTunnel,
250
+ persistedTunnel,
251
+ shell,
252
+ shellArgs,
253
+ cwd,
254
+ defaultShell,
255
+ version,
256
+ logLevel,
257
+ };
231
258
  }
232
259
 
233
260
  module.exports = { parseArgs, printHelp };