fix(release): keep plugin pack output machine-readable

This commit is contained in:
Vincent Koc
2026-07-11 17:45:29 +08:00
committed by Vincent Koc
parent 14a056ac83
commit a8ce892909
2 changed files with 37 additions and 10 deletions

View File

@@ -295,7 +295,7 @@ function installMissingOptionalBundledDependencies(params) {
{
cwd: params.packageDir,
env: process.env,
stdio: ["ignore", "inherit", "inherit"],
stdio: ["ignore", "ignore", "inherit"],
},
);
if (result.error) {

View File

@@ -446,15 +446,42 @@ describe("plugin npm package manifest staging", () => {
});
const nodeModulesPath = join(packageDir, "node_modules");
withAugmentedPluginNpmManifestForPackage(
{ repoRoot: repoDir, packageDir, bundleDependencies: true },
() => {
expect(existsSync(join(nodeModulesPath, "local-runtime-dep", "package.json"))).toBe(true);
expect(existsSync(join(nodeModulesPath, "optional-platform-dep", "package.json"))).toBe(
true,
);
},
);
const manifestModuleUrl = new URL(
"../scripts/lib/plugin-npm-package-manifest.mjs",
import.meta.url,
).href;
const childSource = `
import { existsSync } from "node:fs";
import { join } from "node:path";
import { withAugmentedPluginNpmManifestForPackage } from ${JSON.stringify(manifestModuleUrl)};
const packageDir = ${JSON.stringify(packageDir)};
const nodeModulesPath = ${JSON.stringify(nodeModulesPath)};
withAugmentedPluginNpmManifestForPackage(
{
repoRoot: ${JSON.stringify(repoDir)},
packageDir,
bundleDependencies: true,
},
() => {
if (!existsSync(join(nodeModulesPath, "local-runtime-dep", "package.json"))) {
throw new Error("missing bundled runtime dependency");
}
if (!existsSync(join(nodeModulesPath, "optional-platform-dep", "package.json"))) {
throw new Error("missing portable optional bundled dependency");
}
process.stdout.write("pack-json\\n");
},
);
`;
const result = spawnSync(process.execPath, ["--input-type=module", "--eval", childSource], {
cwd: repoDir,
encoding: "utf8",
env: process.env,
});
expect(result.status, result.stderr).toBe(0);
expect(result.stdout).toBe("pack-json\n");
expect(existsSync(nodeModulesPath)).toBe(false);
});