Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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') {
Expand Down