Skip to content
  • Jonathan Hefner's avatar
    455b8e40
    Load Rake tasks only once for command suggestions · 455b8e40
    Jonathan Hefner authored
    Follow-up to #47208.
    
    `UnrecognizedCommandError` calls `printing_commands` to make "Did you
    mean?" suggestions.  `printing_commands` calls `RakeCommand::rake_tasks`,
    which loads the Rake tasks if they have not been memoized.  If the tasks
    have already been loaded by `RakeCommand::perform` (but not memoized by
    `RakeCommand::rake_tasks`), then the tasks will be loaded a second time.
    This can cause, for example, constant redefinition warnings if the task
    files define constants.
    
    Therefore, this commit memoizes the tasks from `RakeCommand::perform`
    before raising `UnrecognizedCommandError`.
    455b8e40
    Load Rake tasks only once for command suggestions
    Jonathan Hefner authored
    Follow-up to #47208.
    
    `UnrecognizedCommandError` calls `printing_commands` to make "Did you
    mean?" suggestions.  `printing_commands` calls `RakeCommand::rake_tasks`,
    which loads the Rake tasks if they have not been memoized.  If the tasks
    have already been loaded by `RakeCommand::perform` (but not memoized by
    `RakeCommand::rake_tasks`), then the tasks will be loaded a second time.
    This can cause, for example, constant redefinition warnings if the task
    files define constants.
    
    Therefore, this commit memoizes the tasks from `RakeCommand::perform`
    before raising `UnrecognizedCommandError`.
Loading