UNPKG

yargs-file-commands

Version:

A yargs helper function that lets you define your commands structure via directory and file naming conventions.

20 lines (19 loc) 804 B
/** * Converts a file path into an array of command segments * @param {string} fullPath - The complete file system path to the command file * @param {string} baseDir - The base directory to make the path relative to * @returns {string[]} Array of segments representing the command hierarchy * * @description * This function processes a file path into command segments by: * 1. Making the path relative to the base directory * 2. Splitting on directory separators * 3. Removing file extensions * 4. Splitting on dots for nested commands * 5. Filtering out empty segments and 'command' keyword * * @example * segmentPath('/base/dir/hello/world.command.ts', '/base/dir') * // Returns: ['hello', 'world'] */ export declare const segmentPath: (fullPath: string, baseDir: string) => string[];