Skip to content

Commit a8ce892

Browse files
committed
fix(release): keep plugin pack output machine-readable
1 parent 14a056a commit a8ce892

2 files changed

Lines changed: 37 additions & 10 deletions

File tree

‎scripts/lib/plugin-npm-package-manifest.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ function installMissingOptionalBundledDependencies(params) {
295295
{
296296
cwd: params.packageDir,
297297
env: process.env,
298-
stdio: ["ignore", "inherit", "inherit"],
298+
stdio: ["ignore", "ignore", "inherit"],
299299
},
300300
);
301301
if (result.error) {

‎test/plugin-npm-package-manifest.test.ts‎

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,42 @@ describe("plugin npm package manifest staging", () => {
446446
});
447447

448448
const nodeModulesPath = join(packageDir, "node_modules");
449-
withAugmentedPluginNpmManifestForPackage(
450-
{ repoRoot: repoDir, packageDir, bundleDependencies: true },
451-
() => {
452-
expect(existsSync(join(nodeModulesPath, "local-runtime-dep", "package.json"))).toBe(true);
453-
expect(existsSync(join(nodeModulesPath, "optional-platform-dep", "package.json"))).toBe(
454-
true,
455-
);
456-
},
457-
);
449+
const manifestModuleUrl = new URL(
450+
"../scripts/lib/plugin-npm-package-manifest.mjs",
451+
import.meta.url,
452+
).href;
453+
const childSource = `
454+
import { existsSync } from "node:fs";
455+
import { join } from "node:path";
456+
import { withAugmentedPluginNpmManifestForPackage } from ${JSON.stringify(manifestModuleUrl)};
457+
458+
const packageDir = ${JSON.stringify(packageDir)};
459+
const nodeModulesPath = ${JSON.stringify(nodeModulesPath)};
460+
withAugmentedPluginNpmManifestForPackage(
461+
{
462+
repoRoot: ${JSON.stringify(repoDir)},
463+
packageDir,
464+
bundleDependencies: true,
465+
},
466+
() => {
467+
if (!existsSync(join(nodeModulesPath, "local-runtime-dep", "package.json"))) {
468+
throw new Error("missing bundled runtime dependency");
469+
}
470+
if (!existsSync(join(nodeModulesPath, "optional-platform-dep", "package.json"))) {
471+
throw new Error("missing portable optional bundled dependency");
472+
}
473+
process.stdout.write("pack-json\\n");
474+
},
475+
);
476+
`;
477+
const result = spawnSync(process.execPath, ["--input-type=module", "--eval", childSource], {
478+
cwd: repoDir,
479+
encoding: "utf8",
480+
env: process.env,
481+
});
482+
483+
expect(result.status, result.stderr).toBe(0);
484+
expect(result.stdout).toBe("pack-json\n");
458485

459486
expect(existsSync(nodeModulesPath)).toBe(false);
460487
});

0 commit comments

Comments
 (0)