Skip to content

Commit 05a79fc

Browse files
authored
Merge pull request #761 from deivid-rodriguez/support_latest_did_you_mean
Support latest did_you_mean
2 parents 5c666b4 + 98dbec7 commit 05a79fc

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/thor/error.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,14 @@ class MalformattedArgumentError < InvocationError
102102
end
103103

104104
if Correctable
105-
DidYouMean::SPELL_CHECKERS.merge!(
106-
'Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
107-
'Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
108-
)
105+
if DidYouMean.respond_to?(:correct_error)
106+
DidYouMean.correct_error(Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
107+
DidYouMean.correct_error(Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
108+
else
109+
DidYouMean::SPELL_CHECKERS.merge!(
110+
'Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
111+
'Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
112+
)
113+
end
109114
end
110115
end

0 commit comments

Comments
 (0)