Skip to content

Export normalisation functions with optional homedir for testability #18

@shellicar

Description

@shellicar

Problem

normaliseInput, normaliseCommand, and expandPath are not exported, and expandPath calls os.homedir() internally. This makes it impossible to unit test path expansion without mocking the OS module or manipulating $HOME.

Solution

Export normaliseInput, normaliseCommand, and expandPath from index.ts, and add an optional homedir parameter so callers can inject a value for testing:

  • expandPath(path, homedir?) -- falls back to os.homedir() when not provided
  • normaliseCommand(command, options?) -- passes options.home through to expandPath
  • normaliseInput(input, options?) -- passes options.home through to normaliseCommand

The MCP stdio server continues to use os.homedir() (which reads $HOME) since there is no reason to override it at that level.

The parameter must be optional everywhere with no behaviour change when omitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions