068a99816b9ede937d6a5c9857259d07e7216c9c

Author
TheEdgeOfRage <git@theedgeofrage.com>
Committer
TheEdgeOfRage <git@theedgeofrage.com>
Date

Message

Use zoxide in herdr-new-workspace dialog

Diff

This diff is truncated to protect this page.

  1diff --git a/dot_local/bin/executable_herdr-new-pi-workspace b/dot_local/bin/executable_herdr-new-pi-workspace
  2index 7159e5eadfd7b847163fc6c1983a1d8a7fc8c764..c9fd42b1dcc17ad20c59cf6f5a0ccf503afd3c8e 100644
  3--- a/dot_local/bin/executable_herdr-new-pi-workspace
  4+++ b/dot_local/bin/executable_herdr-new-pi-workspace
  5@@ -1,35 +1,37 @@
  6 #!/usr/bin/env node
  7-'use strict';
  8+"use strict";
  9 
 10-const fs = require('node:fs/promises');
 11-const os = require('node:os');
 12-const path = require('node:path');
 13-const { randomBytes } = require('node:crypto');
 14-const { spawn, spawnSync } = require('node:child_process');
 15-const readline = require('node:readline/promises');
 16-const process = require('node:process');
 17+const fs = require("node:fs/promises");
 18+const os = require("node:os");
 19+const path = require("node:path");
 20+const { randomBytes } = require("node:crypto");
 21+const { spawn, spawnSync } = require("node:child_process");
 22+const readline = require("node:readline/promises");
 23+const process = require("node:process");
 24 
 25 let prompt;
 26 
 27 class CommandFailure extends Error {
 28   constructor(command, args, result) {
 29-    const stderr = result.stderr?.trim() || 'No stderr output.';
 30+    const stderr = result.stderr?.trim() || "No stderr output.";
 31     super(`Command failed: ${formatCommand(command, args)}\n${stderr}`);
 32   }
 33 }
 34 
 35 function formatCommand(command, args) {
 36-  return [command, ...args].map((value) => JSON.stringify(value)).join(' ');
 37+  return [command, ...args].map((value) => JSON.stringify(value)).join(" ");
 38 }
 39 
 40 function run(command, args) {
 41   const result = spawnSync(command, args, {
 42-    encoding: 'utf8',
 43+    encoding: "utf8",
 44     env: process.env,
 45   });
 46 
 47   if (result.error) {
 48-    throw new Error(`Cannot run ${JSON.stringify(command)}: ${result.error.message}`);
 49+    throw new Error(
 50+      `Cannot run ${JSON.stringify(command)}: ${result.error.message}`,
 51+    );
 52   }
 53 
 54   if (result.status !== 0) {
 55@@ -46,24 +48,26 @@ function findHerdr() {
 56   if (configuredPath) {
 57     candidates.push(configuredPath);
 58   }
 59-  candidates.push('herdr');
 60+  candidates.push("herdr");
 61 
 62   const failures = [];
 63   for (const candidate of [...new Set(candidates)]) {
 64     try {
 65-      run(candidate, ['--version']);
 66+      run(candidate, ["--version"]);
 67       return candidate;
 68     } catch (error) {
 69       failures.push(error.message);
 70     }
 71   }
 72 
 73-  throw new Error(`Cannot run Herdr. Tried ${[...new Set(candidates)].map((candidate) => JSON.stringify(candidate)).join(' and ')}.\n${failures.join('\n')}`);
 74+  throw new Error(
 75+    `Cannot run Herdr. Tried ${[...new Set(candidates)].map((candidate) => JSON.stringify(candidate)).join(" and ")}.\n${failures.join("\n")}`,
 76+  );
 77 }
 78 
 79 function requirePi() {
 80   try {
 81-    run('pi', ['--version']);
 82+    run("pi", ["--version"]);
 83   } catch (error) {
 84     throw new Error(`Cannot run pi from PATH.\n${error.message}`);
 85   }
 86@@ -71,27 +75,31 @@ function requirePi() {
 87 
 88 function requireBash() {
 89   try {
 90-    run('bash', ['--version']);
 91+    run("bash", ["--version"]);
 92   } catch (error) {
 93     throw new Error(`Cannot run bash from PATH.\n${error.message}`);
 94   }
 95 }
 96 
 97 function expandHome(directory) {
 98-  return directory.startsWith('~/')
 99+  return directory.startsWith("~/")
100     ? path.join(os.homedir(), directory.slice(2))
101     : directory;
102 }
103 
104 function promptForDirectory() {