test(package): allow package smoke test during npm publish dry-run - #178
Merged
Merged
Conversation
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.
Closes #177
改动
scripts/test-package.mjs的两个嵌套 npm 命令显式覆盖 dry-run:const packOutput = run("npm", [ "pack", "--json", + // The outer `npm publish --dry-run` propagates npm_config_dry_run into + // this script; force a real tarball for the local smoke test. + "--dry-run=false", "--pack-destination", temporaryDirectory, ]);run("npm", [ "install", "--global", "--prefix", installPrefix, "--omit=dev", "--no-audit", "--no-fund", + // Same npm_config_dry_run propagation; force a real installation. + "--dry-run=false", tarball, ]);根因
外层
npm publish --dry-run通过npm_config_dry_run=true环境变量传播给所有嵌套 npm 命令:npm pack变 dry-run → 不生成 tarball(用户报告的报错)npm install --global同样变空操作 →bin/lint-mdENOENT两处都显式
--dry-run=false后,smoke test 在任何调用路径下都执行真实打包安装;外层 publish 仍是 dry-run,不会上传。验证
npm run test:package(直接调用)npm publish --dry-run(完整 prepublishOnly 链)+ @lint-md/cli@2.3.0/tmp/lint-md-package-*无残留