hugo-extended
Version:
✏️ Plug-and-play binary wrapper for Hugo Extended, the awesomest static-site generator.
30 lines • 1.24 kB
text/typescript
//#region src/lib/args.d.ts
/**
* Build command-line arguments from a command and options object.
*
* This function:
* 1. Loads the Hugo spec to understand flag types
* 2. Converts camelCase property names to kebab-case flags
* 3. Formats values according to their types (boolean, string, number, arrays)
* 4. Returns an argv array ready to pass to child_process
*
* @param command - Hugo command string (e.g., "server", "build", "mod clean").
* @param positionalArgs - Optional array of positional arguments (e.g., paths, names).
* @param options - Options object with camelCase property names.
* @returns Array of command-line arguments.
*
* @example
* buildArgs("server", undefined, { port: 1313, buildDrafts: true })
* // Returns: ["server", "--port", "1313", "--build-drafts"]
*
* @example
* buildArgs("new site", ["my-site"], { format: "yaml" })
* // Returns: ["new", "site", "my-site", "--format", "yaml"]
*
* @example
* buildArgs("build", undefined, { theme: ["a", "b"], minify: true })
* // Returns: ["build", "--theme", "a", "--theme", "b", "--minify"]
*/
declare function buildArgs(command: string, positionalArgs?: string[], options?: Record<string, unknown>): string[];
//#endregion
export { buildArgs };