@dbx-tools/core 0.3.27 → 0.3.29

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 +2 -2
  2. package/src/project.ts +3 -13
package/package.json CHANGED
@@ -12,14 +12,14 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "yaml": "^2.9.0",
15
- "@dbx-tools/shared-core": "0.3.27"
15
+ "@dbx-tools/shared-core": "0.3.29"
16
16
  },
17
17
  "main": "index.ts",
18
18
  "license": "UNLICENSED",
19
19
  "publishConfig": {
20
20
  "access": "public"
21
21
  },
22
- "version": "0.3.27",
22
+ "version": "0.3.29",
23
23
  "types": "index.ts",
24
24
  "type": "module",
25
25
  "exports": {
package/src/project.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { spawnSync } from "node:child_process";
2
2
  import { Stats, readFileSync } from "node:fs";
3
3
  import { basename, dirname, join, resolve } from "node:path";
4
- import { hash, net } from "@dbx-tools/shared-core";
4
+ import { hash, json, net, string } from "@dbx-tools/shared-core";
5
5
  import { statSync as stat } from "./file";
6
6
 
7
7
  const ROOT_MARKERS = [
@@ -219,12 +219,7 @@ export function name(cwd: string = process.cwd()): string {
219
219
  */
220
220
  function repositoryUrlFromGh(cwd?: string): string | undefined {
221
221
  const out = projectContextCommand("gh", ["repo", "view", "--json", "url"], cwd).output;
222
- if (!out) return undefined;
223
- try {
224
- return (JSON.parse(out) as { url?: string }).url?.trim() || undefined;
225
- } catch {
226
- return undefined;
227
- }
222
+ return string.trimToNull(json.parseRecord(out)?.url) ?? undefined;
228
223
  }
229
224
 
230
225
  /** Resolve an ssh host alias (`~/.ssh/config`) to its effective `hostname` via `ssh -G`. */
@@ -302,12 +297,7 @@ export function npmRegistry(cwd?: string): net.UrlBuilder | undefined {
302
297
 
303
298
  function readPackageName(pkgPath: string): string | undefined {
304
299
  if (!stat(pkgPath)?.isFile()) return undefined;
305
- try {
306
- const pkg = JSON.parse(readFileSync(pkgPath, "utf8")) as { name?: string };
307
- return pkg.name?.trim() || undefined;
308
- } catch {
309
- return undefined;
310
- }
300
+ return string.trimToNull(json.parseRecord(readFileSync(pkgPath, "utf8"))?.name) ?? undefined;
311
301
  }
312
302
 
313
303
  if (import.meta.main) {