Skip to content

If a file Buffer is passed to the parser 0 tokens is found without error #546

@pvignau

Description

@pvignau

Versions

  • terrazzo/parser: 0.10.3

Node.js version

24.4.1

OS + version

macOS 26

Description

Seems that the parser handles Buffer differently than the cli. But if it gets one it executes itself without an error.

As seen in the documentation :

const filename = new URL("./tokens/my-tokens.json", import.meta.url);
const { tokens, sources } = await parse(
  [{ filename, src: await fs.readFile(filename) }],
  { config }
);

This runs without any error but do not find any error

The idea here is to update documentation to go from await fs.readFile(filename) to await fs.readFile(filename, 'utf-8') and add an error handling if a buffer is found in the parser.

Reproduction

Use JS API to generate tokens using the doc.

Expected result

If the tokens.json input is filled with DTCG compliant tokens it builds tokens without error

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcli@terrazzo/cliparser@terrazzo/parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions