Skip to content

refactor: use Promise.withResolvers in node-only flows and tests#2378

Merged
ghostdevv merged 1 commit intonpmx-dev:mainfrom
trivikr:promise-with-resolvers
Apr 4, 2026
Merged

refactor: use Promise.withResolvers in node-only flows and tests#2378
ghostdevv merged 1 commit intonpmx-dev:mainfrom
trivikr:promise-with-resolvers

Conversation

@trivikr
Copy link
Copy Markdown
Contributor

@trivikr trivikr commented Apr 4, 2026

🔗 Linked issue

N/A

🧭 Context

This refactor replaces manually constructed deferred promises in Node-only code paths and related tests with Promise.withResolvers.

The goal is to make these flows easier to read, avoid external resolve variable capture, and align the codebase with the Node 24 runtime already required by the project.

📚 Description

This change updates the connector CLI and interactive npm client to use Promise.withResolvers for child-process and PTY lifecycle coordination, rather than wrapping those flows in new Promise(...) with externally assigned resolvers.

It also updates the affected Nuxt component tests to use the same pattern for mocked loading states. The behavior is unchanged; this is a readability and consistency refactor focused on code paths that only run in environments where Promise.withResolvers is available.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Apr 4, 2026 7:02pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Apr 4, 2026 7:02pm
npmx-lunaria Ignored Ignored Apr 4, 2026 7:02pm

Request Review

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 916eb1bb-48bb-4466-b3a7-d0253fdbc746

📥 Commits

Reviewing files that changed from the base of the PR and between 23dc158 and ab078a1.

📒 Files selected for processing (4)
  • cli/src/cli.ts
  • cli/src/npm-client.ts
  • test/nuxt/components/Package/Versions.spec.ts
  • test/nuxt/components/VersionSelector.spec.ts

📝 Walkthrough

Walkthrough

This pull request refactors promise construction across multiple files to use Promise.withResolvers<T>() instead of manually creating promises with new Promise(...). The changes affect two production files in the CLI module (runNpmLogin() in cli/src/cli.ts and execNpmInteractive() in cli/src/npm-client.ts) and two test files that handle promise resolution patterns. The refactoring maintains existing functionality whilst changing how resolve functions are captured and wired, shifting code structure without altering observable runtime behaviour.

Suggested reviewers

  • alexdln
  • ghostdevv
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the refactor from manual promise construction to Promise.withResolvers across CLI, npm client, and test files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@ghostdevv ghostdevv left a comment

Choose a reason for hiding this comment

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

ty!!

@ghostdevv ghostdevv added this pull request to the merge queue Apr 4, 2026
Merged via the queue into npmx-dev:main with commit 0b68aea Apr 4, 2026
21 checks passed
@trivikr trivikr deleted the promise-with-resolvers branch April 4, 2026 20:13
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.

2 participants