security/codeql-dependabot-gitleaks
| 1 | import meant from "meant" |
| 2 | |
| 3 | export function didYouMean(scmd, commands): string { |
| 4 | const bestSimilarity = meant(scmd, commands).map((str) => { |
| 5 | return ` ${str}` |
| 6 | }) |
| 7 | |
| 8 | if (bestSimilarity.length === 0) return `` |
| 9 | if (bestSimilarity.length === 1) { |
| 10 | return `\nDid you mean this?\n ${bestSimilarity[0]}\n` |
| 11 | } else { |
| 12 | return ( |
| 13 | [`\nDid you mean one of these?`] |
| 14 | .concat(bestSimilarity.slice(0, 3)) |
| 15 | .join(`\n`) + `\n` |
| 16 | ) |
| 17 | } |
| 18 | } |