Files
medusa-store/packages/medusa-cli/src/did-you-mean.ts
T
Adrien de Peretti 6f1fa244fa chore(medusa-cli): Cleanup plugin setup (#4420)
* chore(medusa-cli): Cleanup plugin setup

* fix: logger types

* fix event bus local

* fix event bus redis

* Create late-dragons-collect.md

* move to ts

* remove unused command

* env

* fix
2023-06-28 16:37:25 +02:00

19 lines
459 B
TypeScript

import meant from "meant"
export function didYouMean(scmd, commands): string {
const bestSimilarity = meant(scmd, commands).map((str) => {
return ` ${str}`
})
if (bestSimilarity.length === 0) return ``
if (bestSimilarity.length === 1) {
return `\nDid you mean this?\n ${bestSimilarity[0]}\n`
} else {
return (
[`\nDid you mean one of these?`]
.concat(bestSimilarity.slice(0, 3))
.join(`\n`) + `\n`
)
}
}