Skip to content

Commit

Permalink
change to printing diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-dulaimi committed Feb 18, 2023
1 parent 9cea407 commit d909d33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 11 additions & 10 deletions helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const diffFieldOverrides = async (targetFile: any) => {
return missingFieldOverrides;
};

export const printDiffs = (
export const writeDiffs = async (
missingIndexes: any[],
missingFieldOverrides: any[],
) => {
Expand All @@ -100,9 +100,11 @@ export const printDiffs = (
if (missingIndexes.length > 0) {
spinner.start();

missingIndexes.forEach((missingIndex) => {
console.log('\n\n\r', chalk.red(JSON.stringify(missingIndex, null, 2)));
});
await fs.writeFile(
path.join(process.cwd(), 'diff-indexes.json'),
JSON.stringify(missingIndexes, null, 2),
);

spinner.stop();
}

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

spinner.start();

missingFieldOverrides.forEach((missingFieldOverride) => {
console.log(
'\n\n\r',
chalk.red(JSON.stringify(missingFieldOverride, null, 2)),
);
});
await fs.writeFile(
path.join(process.cwd(), 'diff-field-overrides.json'),
JSON.stringify(missingFieldOverrides, null, 2),
);

spinner.stopAndPersist();
}
};
4 changes: 2 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
diffFieldOverrides,
diffIndexes,
getParsedFiles,
printDiffs
writeDiffs
} from './helpers.js';
import { ProgramArgs } from './types.js';

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

printDiffs(missingIndexes, missingFieldOverrides);
writeDiffs(missingIndexes, missingFieldOverrides);
}

0 comments on commit d909d33

Please sign in to comment.