fix(cli): prevent double extension in temp file for stdin markdown with --ext#1399
fix(cli): prevent double extension in temp file for stdin markdown with --ext#1399antongolub merged 1 commit intogoogle:mainfrom
Conversation
…th --ext .md Pass EXT (.mjs) explicitly when creating the temp file after markdown transformation to avoid falling back to argv.ext, which caused the temp file to be named zx.md.md instead of zx.md.mjs.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Let's try this: |
|
Thank you for the suggestion, @antongolub! I did consider using Here’s my understanding of the behavior when reading from stdin with
If we apply That said, applying your suggestion at line 231 does make sense to me, as it would avoid an unnecessary reassignment when |
|
@antongolub |
Fixes the issue where
echo '...' | npx zx --ext='.md'produces a temp file namedzx.md.md, causing Node.js to fail withERR_UNKNOWN_FILE_EXTENSION.After
transformMarkdown()converts markdown to JavaScript, the temp file should use.mjs. However,getFilepath(dir, base)fell back toargv.ext(.md), resulting in a double extension. This fix explicitly passesEXT(.mjs) to prevent the fallback.Before
After
npm buildbefore committing and verified the bundle updates correctly.run testand confirmed all tests succeed.