chore: convert CLI run command to ESM#6014
Open
macayu17 wants to merge 4 commits into
Open
Conversation
|
|
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR migrates Mocha’s default CLI run command module toward ESM usage and updates command exports/tests accordingly.
Changes:
- Convert
lib/cli/run.jsfrom CommonJS (require/exports) to ESM (import/export). - Update CLI command re-exports to reference an ESM
runmodule. - Add a unit test asserting the
runcommand module is importable via ESM.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/node-unit/cli/run.spec.js | Updates the test import path and adds an ESM-module availability test for the run command. |
| lib/cli/run.js | Converts the run command implementation from CJS to ESM and updates imports/exports accordingly. |
| lib/cli/commands.mjs | Switches the default run command export to reference an ESM module. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6014 +/- ##
==========================================
- Coverage 80.89% 80.87% -0.03%
==========================================
Files 64 64
Lines 4602 4596 -6
Branches 976 975 -1
==========================================
- Hits 3723 3717 -6
Misses 879 879 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
macayu17
force-pushed
the
fix/5967-cli-esm
branch
2 times, most recently
from
May 25, 2026 04:10
8d78b65 to
bf7fde7
Compare
macayu17
force-pushed
the
fix/5967-cli-esm
branch
from
May 25, 2026 04:11
bf7fde7 to
fcc7c7c
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
lib/cli/files to ESM #5967status: accepting prsOverview
Converts
lib/cli/run.jstolib/cli/run.mjsas a small slice of the CLI ESM migration.The run command now uses named exports for yargs (
command,describe,builder, andhandler), andcommands.mjsre-exports it as the default run command namespace. I also updated the run command unit test to loadrun.mjsdirectly so this path stays covered.I kept the other files from #5967 alone because they still have the
require()/require.resolve()cases called out in the issue.Checked with:
npm run test-smokenpm run test-node:unitnpm run tscnpm run clean; npm run buildnpx eslint --max-warnings 0 lib/cli/run.mjs lib/cli/commands.mjs test/node-unit/cli/run.spec.jsnpx prettier --check lib/cli/run.mjs lib/cli/commands.mjs test/node-unit/cli/run.spec.js