Skip to content

Commit c09820e

Browse files
authored
Show error status for failed patches (#439)
1 parent e2af89e commit c09820e

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,20 @@ function printPatchResults(results: PatchResult[]): void {
9797
for (const group of groupOrder) {
9898
const groupResults = byGroup.get(group)!;
9999

100-
// Filter based on --show-unchanged
101-
const filtered = groupResults.filter(r => r.applied || isShowUnchanged());
100+
// Filter based on --show-unchanged (but always show applied and failed)
101+
const filtered = groupResults.filter(
102+
r => r.applied || r.failed || isShowUnchanged()
103+
);
102104
if (filtered.length === 0) continue;
103105

104106
console.log(`\n ${chalk.bold(group)}:`);
105107

106108
for (const result of filtered) {
107-
const status = result.applied ? chalk.green('✓') : chalk.dim('○');
109+
const status = result.failed
110+
? chalk.red('✗')
111+
: result.applied
112+
? chalk.green('✓')
113+
: chalk.dim('○');
108114
const details = result.details ? `: ${result.details}` : '';
109115
// Show description in gray on the same line for applied patches only
110116
const description =

src/patches/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export interface PatchResult {
110110
name: string;
111111
group: PatchGroup;
112112
applied: boolean;
113+
failed?: boolean;
113114
details?: string;
114115
description?: string;
115116
}
@@ -162,9 +163,10 @@ const applyPatches = (
162163

163164
debug(`Applying patch: ${patch.name}`);
164165
const result = patch.fn(content);
165-
const applied = result !== null;
166+
const failed = result === null;
167+
const applied = !failed && result !== content;
166168

167-
if (applied) {
169+
if (!failed) {
168170
content = result;
169171
}
170172

@@ -173,6 +175,7 @@ const applyPatches = (
173175
name: patch.name,
174176
group: patch.group,
175177
applied,
178+
failed,
176179
description: patch.description,
177180
});
178181
}

0 commit comments

Comments
 (0)