@williamthorsen/nmr-core 0.10.0 → 0.10.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.
package/README.md CHANGED
@@ -4,15 +4,7 @@ Shared utilities for node-monorepo-tools packages.
4
4
 
5
5
  This package serves as the shared library foundation for the monorepo. For the nmr CLI tool, see [`@williamthorsen/nmr`](../nmr).
6
6
 
7
- <!-- section:release-notes -->
8
- ## Release notes — v0.10.0 (2026-08-13)
9
-
10
- ### 🎉 Features
11
-
12
- - Print a retained run with nmr --log (#669)
13
-
14
- Adds `nmr --log <command>`, which prints what the last recorded pass wrote instead of running the command again. The whole transcript, up to a limit of 256 KiB, is now saved for any passing command that is not writing straight to a terminal; `--log` prints it under a header giving the instant, the duration, and the command chain that succeeded. The log of a composite is the sum of its constituents' excerpts. If a change disqualifies the recording, `--log` instead reports the change.
15
- <!-- /section:release-notes -->
7
+ <!-- section:release-notes --><!-- /section:release-notes -->
16
8
 
17
9
  ## Installation
18
10
 
@@ -0,0 +1,3 @@
1
+ export declare function hasErrnoCode(error: unknown, code: string): error is Error & {
2
+ code: string;
3
+ };
@@ -0,0 +1,4 @@
1
+ import { isError } from '@williamthorsen/toolbelt.errors';
2
+ export function hasErrnoCode(error, code) {
3
+ return isError(error) && 'code' in error && error.code === code;
4
+ }
@@ -4,6 +4,7 @@ import { existsSync, lstatSync, readFileSync, readlinkSync } from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import { describeError } from '@williamthorsen/toolbelt.errors';
6
6
  import { GIT_OUTPUT_LIMIT } from "./gitOutputLimit.js";
7
+ import { hasErrnoCode } from "./hasErrnoCode.js";
7
8
  const HASH_FORMAT = 'nmr-working-tree-v1';
8
9
  const PRECEDING_FIELD_COUNTS = {
9
10
  1: 8,
@@ -112,7 +113,7 @@ function digestPathContent(toplevel, relativePath) {
112
113
  stats = lstatSync(absolutePath);
113
114
  }
114
115
  catch (error) {
115
- if (isErrorWithCode(error, 'ENOENT')) {
116
+ if (hasErrnoCode(error, 'ENOENT')) {
116
117
  return { ok: true, kind: 'absent', digest: '' };
117
118
  }
118
119
  return { ok: false, reason: `could not stat ${relativePath}: ${describeError(error)}` };
@@ -145,9 +146,6 @@ function extractPath(record, precedingFieldCount) {
145
146
  const extracted = record.slice(index);
146
147
  return extracted === '' ? undefined : extracted;
147
148
  }
148
- function isErrorWithCode(error, code) {
149
- return error instanceof Error && 'code' in error && error.code === code;
150
- }
151
149
  function runGit(args, cwd) {
152
150
  const result = spawnSync('git', args, { cwd, encoding: 'utf8', maxBuffer: GIT_OUTPUT_LIMIT });
153
151
  if (result.error) {
@@ -3,6 +3,7 @@ export type { CacheDirRef, CacheEntryRef } from './cache-store.js';
3
3
  export { readCacheEntry, readJsonCacheEntry, removeCacheDir, removeCacheEntry, resolveCacheDir, resolveCacheEntryPath, writeCacheEntry, } from './cache-store.js';
4
4
  export { findPackageRoot } from './findPackageRoot.js';
5
5
  export { GIT_OUTPUT_LIMIT } from './gitOutputLimit.js';
6
+ export { hasErrnoCode } from './hasErrnoCode.js';
6
7
  export type { WorkingTreeHashResult } from './hashWorkingTree.js';
7
8
  export { hashWorkingTree, readHeadSha } from './hashWorkingTree.js';
8
9
  export type { FlagDefinition, FlagSchema, ParseArgsOptions, ParsedArgs, ParsedFlags, ParseErrorKind, } from './parseArgs.js';
package/dist/esm/index.js CHANGED
@@ -2,6 +2,7 @@ export const PACKAGE_NAME = '@williamthorsen/nmr-core';
2
2
  export { readCacheEntry, readJsonCacheEntry, removeCacheDir, removeCacheEntry, resolveCacheDir, resolveCacheEntryPath, writeCacheEntry, } from "./cache-store.js";
3
3
  export { findPackageRoot } from "./findPackageRoot.js";
4
4
  export { GIT_OUTPUT_LIMIT } from "./gitOutputLimit.js";
5
+ export { hasErrnoCode } from "./hasErrnoCode.js";
5
6
  export { hashWorkingTree, readHeadSha } from "./hashWorkingTree.js";
6
7
  export { parseArgs, parseArgsOrExit, ParseError } from "./parseArgs.js";
7
8
  export { readPackageVersion } from "./readPackageVersion.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@williamthorsen/nmr-core",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "private": false,
5
5
  "description": "Shared utilities for node-monorepo-tools packages",
6
6
  "keywords": [
@@ -32,7 +32,11 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@williamthorsen/toolbelt.errors": "0.4.0"
35
+ "@williamthorsen/toolbelt.errors": "0.5.0"
36
+ },
37
+ "devDependencies": {
38
+ "@williamthorsen/toolbelt.testing": "0.3.0",
39
+ "@williamthorsen/toolbelt.vitest": "0.4.0"
36
40
  },
37
41
  "engines": {
38
42
  "node": ">=24"