Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expanded missing command error, including 'did you mean' (#6496)
close #6492 Co-authored-by: Zoltan Kochan <z@kochan.io>
- Loading branch information
1 parent
d58cdb9
commit ee429b3
Showing
12 changed files
with
120 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@pnpm/plugin-commands-script-runners": minor | ||
"@pnpm/cli-utils": patch | ||
"pnpm": patch | ||
--- | ||
|
||
Expanded missing command error, including 'did you mean' [#6492](https://github.com/pnpm/pnpm/issues/6492). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
exec/plugin-commands-script-runners/src/buildCommandNotFoundHint.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { type PackageScripts } from '@pnpm/types' | ||
import didYouMean, { ReturnTypeEnums } from 'didyoumean2' | ||
|
||
export function buildCommandNotFoundHint (scriptName: string, scripts?: PackageScripts | undefined) { | ||
let hint = `Command "${scriptName}" not found.` | ||
|
||
const nearestCommand = scripts && didYouMean(scriptName, Object.keys(scripts), { | ||
returnType: ReturnTypeEnums.FIRST_CLOSEST_MATCH, | ||
}) | ||
|
||
if (nearestCommand) { | ||
hint += ` Did you mean "pnpm run ${nearestCommand}"?` | ||
} | ||
|
||
return hint | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.