fix(core): resolve docs.mjs package dir with fileURLToPath so component docs work on Windows#3331
fix(core): resolve docs.mjs package dir with fileURLToPath so component docs work on Windows#3331arham766 wants to merge 1 commit into
Conversation
|
@arham766 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @arham766! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
bcfb037 to
ceba940
Compare
…s on Windows URL.pathname returns /D:/... for drive-letter paths, so --list printed nothing and component lookup crashed with ENOENT. Adds subprocess smoke tests that pin the behavior on all platforms.
ceba940 to
a4956dc
Compare
|
@cixzhang gentle ping when you have a minute. Small fix, unblocks Windows users of the core docs script (both --list and single-component lookup are broken there today). |
Summary
docs.mjsresolved its package directory withnew URL(import.meta.url).pathname, which returns/D:/...for drive-letter paths on Windows.srcDirthen pointed at a nonexistentD:\D:\...path, so--listsilently printed nothing (theexistsSyncguard returned an empty catalog) and single-component lookup crashed with ENOENT. Switching tofileURLToPathfixes both and makes directory resolution symmetric with the existingpathToFileURLuse inloadDoc().Adds subprocess smoke tests that spawn the script from a neutral cwd (
os.tmpdir()), so resolution can only come from the module URL. The test lives insrc/(not next todocs.mjs) because the vitest include glob only picks uppackages/**/src/**; noted in the file header. No overlap with #3234 (CLI test paths) or #3305 (core build script).Test plan
npx vitest run packages/core/src/docs-script.test.mjspasses on Windows (2/2); the fix is a no-op on POSIX wherefileURLToPathalso correctly decodes percent-encoded paths.node packages/core/docs.mjs --listnow prints the full catalog;node packages/core/docs.mjs Buttonrenders full docs. Before the fix, the former printed nothing and the latter exited with ENOENT.node scripts/check-changesets.mjspasses.