Skip to content

cli: preserve or add trailing slash to file arg

The cli calls path.resolve() to find the users main file. This strips trailing slashes that are maningful to CJS resolution and can cause node to load a different file than users expect. This preserves the trailing slash when we can be sure the user has provided a path to a directory borrowing the pattern from internal/module/cjs/loader.js

Fixes: https://github.com/nodejs/node/issues/24210

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Merge request reports

Loading