Skip to content

Commit d909d33

Browse files
committed
change to printing diffs
1 parent 9cea407 commit d909d33

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

helpers.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const diffFieldOverrides = async (targetFile: any) => {
8989
return missingFieldOverrides;
9090
};
9191

92-
export const printDiffs = (
92+
export const writeDiffs = async (
9393
missingIndexes: any[],
9494
missingFieldOverrides: any[],
9595
) => {
@@ -100,9 +100,11 @@ export const printDiffs = (
100100
if (missingIndexes.length > 0) {
101101
spinner.start();
102102

103-
missingIndexes.forEach((missingIndex) => {
104-
console.log('\n\n\r', chalk.red(JSON.stringify(missingIndex, null, 2)));
105-
});
103+
await fs.writeFile(
104+
path.join(process.cwd(), 'diff-indexes.json'),
105+
JSON.stringify(missingIndexes, null, 2),
106+
);
107+
106108
spinner.stop();
107109
}
108110

@@ -113,12 +115,11 @@ export const printDiffs = (
113115

114116
spinner.start();
115117

116-
missingFieldOverrides.forEach((missingFieldOverride) => {
117-
console.log(
118-
'\n\n\r',
119-
chalk.red(JSON.stringify(missingFieldOverride, null, 2)),
120-
);
121-
});
118+
await fs.writeFile(
119+
path.join(process.cwd(), 'diff-field-overrides.json'),
120+
JSON.stringify(missingFieldOverrides, null, 2),
121+
);
122+
122123
spinner.stopAndPersist();
123124
}
124125
};

main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
diffFieldOverrides,
33
diffIndexes,
44
getParsedFiles,
5-
printDiffs
5+
writeDiffs
66
} from './helpers.js';
77
import { ProgramArgs } from './types.js';
88

@@ -12,5 +12,5 @@ export default async function main(options: ProgramArgs) {
1212
const missingIndexes = await diffIndexes(sourceFile, targetFile);
1313
const missingFieldOverrides = await diffFieldOverrides(targetFile);
1414

15-
printDiffs(missingIndexes, missingFieldOverrides);
15+
writeDiffs(missingIndexes, missingFieldOverrides);
1616
}

0 commit comments

Comments
 (0)