@danypops/vehicle-core 0.6.0 → 0.6.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.
@@ -29,6 +29,8 @@ export interface AtomicJsonWriteOptions {
29
29
  readonly mode?: number;
30
30
  /** Pretty-prints with 2-space indentation (matching JSON.stringify(value, null, 2)) for a human-editable file. Defaults to false (compact). */
31
31
  readonly pretty?: boolean;
32
+ /** Appends a trailing "\n" -- the common POSIX text-file convention. Defaults to false (exact JSON.stringify output, unchanged). */
33
+ readonly trailingNewline?: boolean;
32
34
  }
33
35
  export interface AtomicJsonWriterOptions {
34
36
  readonly fs: AtomicJsonFsAdapter;
@@ -71,6 +71,8 @@ export function createAtomicJsonWriter(options) {
71
71
  }
72
72
  if (serialized === undefined)
73
73
  throw new Error(`atomic-json: value for ${filePath} is not JSON-serializable`);
74
+ if (options?.trailingNewline)
75
+ serialized += "\n";
74
76
  const { dir, base } = dirAndBase(filePath);
75
77
  const tempPath = `${dir}/.${base}.${pid()}.${now()}.${random()}.tmp`;
76
78
  await fsAdapter.writeFile(tempPath, serialized, options?.mode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danypops/vehicle-core",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Vehicle's runtime-neutral wire contract: operation descriptors, schema codecs, failure shapes. Zero runtime dependencies, zero Bun-specific code -- the one thing every Vehicle client and server package depends on.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -31,6 +31,8 @@ export interface AtomicJsonWriteOptions {
31
31
  readonly mode?: number;
32
32
  /** Pretty-prints with 2-space indentation (matching JSON.stringify(value, null, 2)) for a human-editable file. Defaults to false (compact). */
33
33
  readonly pretty?: boolean;
34
+ /** Appends a trailing "\n" -- the common POSIX text-file convention. Defaults to false (exact JSON.stringify output, unchanged). */
35
+ readonly trailingNewline?: boolean;
34
36
  }
35
37
 
36
38
  export interface AtomicJsonWriterOptions {
@@ -118,6 +120,7 @@ export function createAtomicJsonWriter(options: AtomicJsonWriterOptions): Atomic
118
120
  throw new Error(`atomic-json: value for ${filePath} is not JSON-serializable`, { cause: error });
119
121
  }
120
122
  if (serialized === undefined) throw new Error(`atomic-json: value for ${filePath} is not JSON-serializable`);
123
+ if (options?.trailingNewline) serialized += "\n";
121
124
  const { dir, base } = dirAndBase(filePath);
122
125
  const tempPath = `${dir}/.${base}.${pid()}.${now()}.${random()}.tmp`;
123
126
  await fsAdapter.writeFile(tempPath, serialized, options?.mode);