All files / core/semantic-log/src version.ts

100% Statements 20/20
100% Branches 0/0
100% Functions 0/0
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * The emitter's own version, carried as a base field (PRD R20; ยง5.1 "Base
 * fields (pid, hostname, service, version)").
 *
 * Read from the manifest rather than duplicated as a literal so the value
 * cannot drift from `package.json`. It is read with `readFileSync` and not
 * imported as JSON: the `tap` TypeScript loader drops import attributes when it
 * transpiles, so `import ... with {type: 'json'}` works under plain `node` but
 * makes every test file that transitively imports the logger fail to load. The
 * base fields identify the process that emitted the record, so the default is
 * *this* package's version; a service that wants its own version passes one to
 * `createLogger` (see `LoggerOptions.version`).
 */
 
import {readFileSync} from 'node:fs';
 
/** This package's version, read from its manifest at module load. */
export const packageVersion: string = (
    JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as {version: string}
).version;