diff --git a/src/index.ts b/src/index.ts index f448efd..a537d50 100644 --- a/src/index.ts +++ b/src/index.ts @@ -147,18 +147,22 @@ async function getTools( } const options = [ - { value: 'biome', label: 'Biome (linting & formatting)' }, - { value: 'eslint', label: 'ESLint (linting)' }, - { value: 'prettier', label: 'Prettier (formatting)' }, + { value: 'biome', label: 'Biome - linting & formatting' }, + { value: 'eslint', label: 'ESLint - linting' }, + { value: 'prettier', label: 'Prettier - formatting' }, ]; if (extraTools) { + const normalize = (tool: ExtraTool) => ({ + value: tool.value, + label: tool.label, + hint: tool.command, + }); + options.unshift( + ...extraTools.filter((tool) => tool.order === 'pre').map(normalize), + ); options.push( - ...extraTools.map((tool) => ({ - value: tool.value, - label: tool.label, - hint: tool.command, - })), + ...extraTools.filter((tool) => tool.order !== 'pre').map(normalize), ); } @@ -230,6 +234,11 @@ type ExtraTool = { * The custom command to run when the tool is selected. */ command?: string; + /** + * Specify where to display this tool. + * If undefined, the tool will be displayed after built-in tools. + */ + order?: 'pre' | 'post'; }; function runCommand(command: string, cwd: string, packageManager: string) { @@ -244,9 +253,9 @@ function runCommand(command: string, cwd: string, packageManager: string) { const replacement = createReplacements[packageManager]; if (replacement) { command = command - .replace(/^npm create /, replacement) + .replace('npm create ', replacement) // other package managers don't need the extra `--` - .replace(/ -- --/, ' --'); + .replace(' -- --', ' --'); } // Yarn v1 does not support `@latest` tag if (packageManager === 'yarn') {