diffx-cli 0.8.0 → 0.8.1

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/dist/cli.mjs +22 -20
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
4
4
  import { basename, dirname, extname, isAbsolute, join, resolve } from "node:path";
5
5
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import getPort from "get-port";
7
- import { execSync } from "node:child_process";
7
+ import { execFileSync } from "node:child_process";
8
8
  import { parseSync } from "editorconfig";
9
9
  import { readFile } from "node:fs/promises";
10
10
  import { Hono } from "hono";
@@ -46,51 +46,51 @@ function getFileContent(filePath, version) {
46
46
  return null;
47
47
  }
48
48
  try {
49
- return execSync(`git show HEAD:${filePath}`, { maxBuffer: 50 * 1024 * 1024 });
49
+ return execFileSync("git", ["show", `HEAD:${filePath}`], { maxBuffer: 50 * 1024 * 1024 });
50
50
  } catch {
51
51
  return null;
52
52
  }
53
53
  }
54
54
  function isGitRepo() {
55
55
  try {
56
- execSync("git rev-parse --is-inside-work-tree", { stdio: "pipe" });
56
+ execFileSync("git", ["rev-parse", "--is-inside-work-tree"], { stdio: "pipe" });
57
57
  return true;
58
58
  } catch {
59
59
  return false;
60
60
  }
61
61
  }
62
62
  function getRepoRoot() {
63
- return execSync("git rev-parse --show-toplevel", { encoding: "utf-8" }).trim();
63
+ return execFileSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf-8" }).trim();
64
64
  }
65
65
  function getRepoName() {
66
66
  return basename(getRepoRoot());
67
67
  }
68
68
  function getBranchName() {
69
69
  try {
70
- return execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf-8" }).trim();
70
+ return execFileSync("git", [
71
+ "rev-parse",
72
+ "--abbrev-ref",
73
+ "HEAD"
74
+ ], { encoding: "utf-8" }).trim();
71
75
  } catch {
72
76
  return "";
73
77
  }
74
78
  }
75
79
  function getCustomGitDiff(args) {
76
- return execSync([
77
- "git",
78
- "diff",
79
- ...args
80
- ].join(" "), {
80
+ return execFileSync("git", ["diff", ...args], {
81
81
  encoding: "utf-8",
82
82
  maxBuffer: 50 * 1024 * 1024
83
83
  });
84
84
  }
85
85
  function getGitDiff(options = {}) {
86
86
  const parts = [];
87
- const unstaged = execSync("git diff", {
87
+ const unstaged = execFileSync("git", ["diff"], {
88
88
  encoding: "utf-8",
89
89
  maxBuffer: 50 * 1024 * 1024
90
90
  });
91
91
  if (unstaged) parts.push(unstaged);
92
92
  if (options.staged) {
93
- const staged = execSync("git diff --staged", {
93
+ const staged = execFileSync("git", ["diff", "--staged"], {
94
94
  encoding: "utf-8",
95
95
  maxBuffer: 50 * 1024 * 1024
96
96
  });
@@ -115,7 +115,11 @@ function getTabSizeForFiles(filePaths) {
115
115
  }
116
116
  function getUntrackedFilesDiff() {
117
117
  const root = getRepoRoot();
118
- const output = execSync("git ls-files --others --exclude-standard", {
118
+ const output = execFileSync("git", [
119
+ "ls-files",
120
+ "--others",
121
+ "--exclude-standard"
122
+ ], {
119
123
  encoding: "utf-8",
120
124
  maxBuffer: 50 * 1024 * 1024
121
125
  }).trim();
@@ -369,7 +373,8 @@ function startServer(options) {
369
373
  return new Promise((resolve) => {
370
374
  serve({
371
375
  fetch: app.fetch,
372
- port: options.port
376
+ port: options.port,
377
+ hostname: "127.0.0.1"
373
378
  }, (info) => {
374
379
  resolve({ port: info.port });
375
380
  });
@@ -432,12 +437,9 @@ const { port: actualPort } = await startServer({
432
437
  clientDir: existsSync(clientDir) ? clientDir : resolve(process.cwd(), "dist/client"),
433
438
  customDiffArgs
434
439
  });
435
- console.log(`diffx server running at http://localhost:${actualPort}`);
436
- if (!values["no-open"]) {
437
- const openModule = await import("open");
438
- const url = `http://localhost:${actualPort}`;
439
- openModule.default(url);
440
- }
440
+ const localUrl = `http://127.0.0.1:${actualPort}`;
441
+ console.log(`diffx server running at ${localUrl}`);
442
+ if (!values["no-open"]) (await import("open")).default(localUrl);
441
443
  process.on("SIGINT", () => {
442
444
  console.log("\nShutting down...");
443
445
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diffx-cli",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Local code review tool for git diffs with a GitHub PR-like web UI",
5
5
  "type": "module",
6
6
  "license": "MIT",