Function runner

  • Parameters

    • argv: string[]

      The CLI-style arguments (e.g. ['init', 'self']).

    • config: RunnerConfig

      The runner configuration (templates, logger, cwd, prompter).

    Returns Promise<RunnerResult>

    The run result: success flag, elapsed time and per-operation actions.

    Description

    Programmatic entry point of the generator. Resolves the config (templates directory and .hygen.js), runs the engine pipeline and normalises the outcome into a RunnerResult. A ShowHelpError is routed to printHelp.

    Example

    import { runner, Logger } from '@biorate/hygen';

    const result = await runner(['app', 'new', '--name', 'myapp'], {
    cwd: process.cwd(),
    templates: '_templates',
    logger: new Logger((msg) => console.log(msg)),
    exec: (sh, body) => {},
    createPrompter: () => require('enquirer'),
    });

    console.log(result.success); // true