Skip to content

Commit 6191ce9

Browse files
committed
feat:support specify order for extra tools
1 parent 54ac26a commit 6191ce9

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

src/index.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,22 @@ async function getTools(
147147
}
148148

149149
const options = [
150-
{ value: 'biome', label: 'Biome (linting & formatting)' },
151-
{ value: 'eslint', label: 'ESLint (linting)' },
152-
{ value: 'prettier', label: 'Prettier (formatting)' },
150+
{ value: 'biome', label: 'Biome - linting & formatting' },
151+
{ value: 'eslint', label: 'ESLint - linting' },
152+
{ value: 'prettier', label: 'Prettier - formatting' },
153153
];
154154

155155
if (extraTools) {
156+
const normalize = (tool: ExtraTool) => ({
157+
value: tool.value,
158+
label: tool.label,
159+
hint: tool.command,
160+
});
161+
options.unshift(
162+
...extraTools.filter((tool) => tool.order === 'pre').map(normalize),
163+
);
156164
options.push(
157-
...extraTools.map((tool) => ({
158-
value: tool.value,
159-
label: tool.label,
160-
hint: tool.command,
161-
})),
165+
...extraTools.filter((tool) => tool.order !== 'pre').map(normalize),
162166
);
163167
}
164168

@@ -230,6 +234,10 @@ type ExtraTool = {
230234
* The custom command to run when the tool is selected.
231235
*/
232236
command?: string;
237+
/**
238+
* Specify the display order
239+
*/
240+
order?: 'pre' | 'post';
233241
};
234242

235243
function runCommand(command: string, cwd: string, packageManager: string) {

0 commit comments

Comments
 (0)