Skip to content

Conversation

@Jarred-Sumner
Copy link
Collaborator

What does this PR do?

This adds a "did you mean" suggestion for similarly-named package.json scripts. It only appears for package.json scripts if it finds one that is similarly named. To choose a similarly named command, it uses Jaro-Winkler with a distance of 0.7, which is what clap uses.

image

How did you verify your code works?

Test

@robobun
Copy link
Collaborator

robobun commented May 6, 2025

Updated 11:30 PM PT - May 5th, 2025

@Jarred-Sumner, your commit f9919b0bdd34369aff45a4c64ab2ef55784c22f9 passed in Build #16161! 🎉


🧪   To try this PR locally:

bunx bun-pr 19493

That installs a local version of the PR into your bun-19493 executable, so you can run:

bun-19493 --bun

@Jarred-Sumner Jarred-Sumner requested review from a team, nektro and paperclover and removed request for a team and paperclover May 6, 2025 13:25
@Electroid
Copy link
Contributor

Do we want to use the note: message style for this?

&.{ "b", CSI ++ "1m" },
&.{ "d", CSI ++ "2m" },
&.{ "i", CSI ++ "3m" },
&.{ "u", CSI ++ "4m" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update the doc comment?


/// Calculate the Jaro-Winkler similarity between two strings.
/// Returns a value between 0.0 (completely different) and 1.0 (identical).
fn jaroWinkler(s1: []const u8, s2: []const u8) f64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does Jaro-Winkler compare with Levenshtein?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its better imo

argv0.len -= extname.len;
}

Output.prettyError("\nDid you mean \"{s}\"?\n\n <cyan><d>{s} <r><cyan><u>{s}<r>\n", .{ entry, argv0, entry });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this have the correct output for both bun devv and bun run devv ? and can there be a test for that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a test yeah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants