Skip to content

Conversation

@JoshuaKGoldberg
Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg commented Nov 5, 2025

Purpose of this pull request?

  • Documentation update
  • Bug fix
  • Enhancement
  • Other, please explain: Internal refactor

Fixes #509.

What changes did you make?

Replaces all remaining uses of .then/.catch with async/await.

Is there anything you'd like reviewers to focus on?

The issue is actually for moving from the older cb callbacks to Promises. That'd already been done. This moves the codebase further along.

assert.rejects(
this.router.navigate.bind(this.router, 'invalid route name'),
'No routes called: invalid route name',
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example failure of this test on
https://github.com/yeoman/yo/actions/runs/19107048177/job/54593675005?pr=918:

  1) Router
       #navigate()
         throws on invalid route name:
     AssertionError [ERR_ASSERTION]: Missing expected exception.
      at Context.<anonymous> (file:///Users/runner/work/yo/yo/test/router.js:59:14)

Two existing problems with the test:

  • It's this.router, not this.route
  • The function returns a Promise, so the test should be testing what it rejects, not throws

Previously it was synchronously throwing an error because this was undefined (yay, JavaScript quirks!). Switching from synchronous Promise creation to async changes the code to all be asynchronous. Now it asynchronously rejects (throws) the No routes called: ${name}.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review November 5, 2025 15:35
@mshima mshima merged commit 1a9ca65 into main Nov 5, 2025
23 checks passed
@mshima mshima deleted the async-await-ify branch November 5, 2025 17:10
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.

Promisify the codebase

3 participants