Skip to content

Commit

Permalink
feat: showing just scripts that aren't pre/post anything
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorHo committed Apr 23, 2024
1 parent 1ff58f1 commit 05320d8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ export default class MainCli {
if (!scripts) {
p.log.info('We couldn\'t find any script in your package.json.\nEnsure you have a script there so we can include it into your git hook.');
} else {
// TODO: We can remove scripts from the "pre", "post" cycles [https://docs.npmjs.com/cli/v6/using-npm/scripts#pre--post-scripts]
scriptsChoosed = (await p.multiselect({
message: `Which scripts you want to execute on the ${hook} hook?`,
options: Object.keys(scripts).map(key => ({
const availableScripts: { label: string; value: string }[] = [];
Object.keys(scripts).forEach(key => {
if (!key.startsWith('pre') && !key.startsWith('post')) availableScripts.push({
label: key,
value: key,
})),
});
});

scriptsChoosed = (await p.multiselect({
message: `Which scripts you want to execute on the ${hook} hook?`,
options: availableScripts,
})) as string[];
handleCancel(scriptsChoosed);
}
Expand Down

0 comments on commit 05320d8

Please sign in to comment.