@binaryandthread/cli 0.1.2 → 0.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/bin.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  versionLine,
45
45
  warn,
46
46
  working
47
- } from "./chunk-WYCZ6BPV.js";
47
+ } from "./chunk-7FH7BZ3I.js";
48
48
  import {
49
49
  __require
50
50
  } from "./chunk-7OCVIDC7.js";
@@ -73,7 +73,7 @@ function makeLogger(debug, write = (s) => process.stderr.write(s)) {
73
73
  }
74
74
 
75
75
  // src/version.ts
76
- var VERSION = "0.1.2";
76
+ var VERSION = "0.1.3";
77
77
 
78
78
  // src/eggs.ts
79
79
  function teapot() {
@@ -224,6 +224,20 @@ function formatFatal(e, json) {
224
224
  return { out: null, err: `\u2717 ${info.message}`, code: info.code };
225
225
  }
226
226
 
227
+ // src/is-main.ts
228
+ import { realpathSync } from "fs";
229
+ import { fileURLToPath } from "url";
230
+ function isMainModule(argv1, moduleUrl, realpath = realpathSync) {
231
+ if (typeof argv1 !== "string" || argv1.length === 0) return false;
232
+ try {
233
+ const invoked = realpath(argv1);
234
+ const self = realpath(fileURLToPath(moduleUrl));
235
+ return invoked === self;
236
+ } catch {
237
+ return false;
238
+ }
239
+ }
240
+
227
241
  // src/keychain.ts
228
242
  import * as fs from "fs";
229
243
  import * as os from "os";
@@ -366,7 +380,7 @@ function registerBrowse(program, makeClient2, loadConfig2) {
366
380
  program.command("browse").alias("ls").description("list what's in stock on a branch.").option("--branch <branch>", "main (live) or next (terminal-only drops)").option("--plain", "force the static table (skip the interactive picker)").action(async (opts) => {
367
381
  const { json, brand } = resolveOutput(program);
368
382
  if (!json && !opts.plain && brand.color && process.stdout.isTTY) {
369
- const { runInteractiveBrowse } = await import("./interactive-DYY27KBC.js");
383
+ const { runInteractiveBrowse } = await import("./interactive-DZ67P6UX.js");
370
384
  const handled = await runInteractiveBrowse(makeClient2(), loadConfig2(), { branch: opts.branch, brand });
371
385
  if (handled) return;
372
386
  }
@@ -1724,14 +1738,7 @@ function registerEggs(program) {
1724
1738
  });
1725
1739
  program.command("man", { hidden: true }).description("the bt man page (also installed for the system man(1)).").action(() => print(manPage(VERSION).join("\n")));
1726
1740
  }
1727
- var isMain = (() => {
1728
- try {
1729
- return typeof process.argv[1] === "string" && (process.argv[1].endsWith("bin.js") || process.argv[1].endsWith("bin.ts"));
1730
- } catch {
1731
- return false;
1732
- }
1733
- })();
1734
- if (isMain) {
1741
+ if (isMainModule(process.argv[1], import.meta.url)) {
1735
1742
  buildProgram().parseAsync(process.argv).catch((e) => {
1736
1743
  const json = process.argv.includes("--json");
1737
1744
  const { out, err, code } = formatFatal(e, json);