@tnunamak/dalan 0.6.0 → 0.6.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.
@@ -153,7 +153,8 @@ export function tailscaleProvider({ port: wantedPort = TRIAL_PORT, name = 'tails
153
153
  const quote = value => "'" + String(value).replaceAll("'", "'\\''") + "'";
154
154
  const keys = ['HOME', 'PATH', 'XDG_CONFIG_HOME', 'XDG_DATA_HOME', 'XDG_STATE_HOME', 'XDG_RUNTIME_DIR', 'TMPDIR'];
155
155
  const assignments = keys.filter(key => env[key] !== undefined).map(key => `${key}=${quote(env[key])}`);
156
- const command = cli && path.isAbsolute(cli)
156
+ // A rule that someone else replaced is not ours to switch off: offer no port-wide command for it.
157
+ const command = error.code !== 'FUNNEL_RULE_MISMATCH' && cli && path.isAbsolute(cli)
157
158
  ? `(unset ${keys.join(' ')} && ${[...assignments, quote(cli), ...funnelOffArgs(rule.port).map(quote)].join(' ')})`
158
159
  : null;
159
160
  return { removed: false, detail: error.message, ...(command ? { command } : {}) };
@@ -512,6 +513,18 @@ const bundledGozar = () => {
512
513
  }
513
514
  };
514
515
 
516
+ export function resolveGozarCommand({ env = process.env, which = name => whichOnPath(name, env), resolveBundled = bundledGozar } = {}) {
517
+ const bundled = resolveBundled();
518
+ if (bundled) return { binary: process.execPath, args: [bundled] };
519
+ if (env.GOZAR_BIN) {
520
+ try {
521
+ fs.accessSync(env.GOZAR_BIN, fs.constants.X_OK);
522
+ return { binary: env.GOZAR_BIN, args: [] };
523
+ } catch { /* unavailable */ }
524
+ }
525
+ return { binary: which('gozar'), args: [] };
526
+ }
527
+
515
528
  export function gozarProvider({ env = process.env, which = name => whichOnPath(name, env), resolveBundled = bundledGozar, run = execFile, pollMs = 3000, now = Date.now } = {}) {
516
529
  let binary = null, bundled = null, commandCwd = null, port = null, sessionId = null;
517
530
  let endReason = null;
@@ -559,12 +572,9 @@ export function gozarProvider({ env = process.env, which = name => whichOnPath(n
559
572
  name: 'gozar',
560
573
  probe() {
561
574
  commandCwd = process.cwd();
562
- bundled = resolveBundled();
563
- binary = bundled ? process.execPath : null;
564
- if (!binary && env.GOZAR_BIN) {
565
- try { fs.accessSync(env.GOZAR_BIN, fs.constants.X_OK); binary = env.GOZAR_BIN; } catch { /* unavailable */ }
566
- }
567
- binary ??= which('gozar');
575
+ const resolved = resolveGozarCommand({ env, which, resolveBundled });
576
+ binary = resolved.binary;
577
+ bundled = resolved.args[0] ?? null;
568
578
  return binary ? { ok: true } : { ok: false, line: 'Gozar is not installed', fix: 'Install gozar on PATH or set GOZAR_BIN to its executable path.' };
569
579
  },
570
580
  async start({ gatePort, signal, lifetimeEndsAt }) {