Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 0 additions & 111 deletions .github/scripts/__tests__/cli-help-diff.spec.ts

This file was deleted.

23 changes: 15 additions & 8 deletions .github/scripts/cli-help-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ function normalizeOutput(output: string, version: string): string {
.trimEnd();
}

function captureToolHelp(tool: Tool, version: string): string {
function captureToolHelp(tool: Tool, version: string, cwd: string): string {
return tool.commands
.map((command) => {
const result = spawnSync(
'pnpm',
['--silent', 'dlx', `${tool.packageName}@${version}`, ...command],
{
cwd,
encoding: 'utf8',
env: {
...process.env,
Expand All @@ -151,13 +152,19 @@ function captureToolHelp(tool: Tool, version: string): string {
function captureSnapshot(outputPath: string, versionsPath?: string): void {
const versions = versionsPath ? (readJson(versionsPath) as VersionMetadata) : undefined;
const tools = {} as Record<ToolName, ToolSnapshot>;
for (const tool of TOOLS) {
const version = readToolVersion(tool, versions);
console.log(`Capturing ${tool.title} ${version} help...`);
tools[tool.name] = {
help: captureToolHelp(tool, version),
version,
};
// Run outside the repository so pnpm dlx does not inherit workspace overrides or patches.
const cwd = mkdtempSync(join(tmpdir(), 'vite-plus-cli-help-capture-'));
try {
for (const tool of TOOLS) {
const version = readToolVersion(tool, versions);
console.log(`Capturing ${tool.title} ${version} help...`);
tools[tool.name] = {
help: captureToolHelp(tool, version, cwd),
version,
};
}
} finally {
rmSync(cwd, { force: true, recursive: true });
}

mkdirSync(dirname(outputPath), { recursive: true });
Expand Down
Loading