Skip to content

Commit c7a1a84

Browse files
committed
fixup! refactor(ng-dev/ts-circular-dependencies): reorder processing of warnings and golden existence check
1 parent a237354 commit c7a1a84

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

ng-dev/ts-circular-dependencies/index.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,7 @@ export function main(
107107
Log.warn(` Please rerun with "--warnings" to inspect unresolved imports.`);
108108
}
109109

110-
if (goldenFile) {
111-
// Golden file exists
112-
if (approve) {
113-
writeFileSync(goldenFile, JSON.stringify(actual, null, 2));
114-
Log.info(green('✔ Updated golden file.'));
115-
return 0;
116-
}
117-
if (!existsSync(goldenFile)) {
118-
Log.error(`x Could not find golden file: ${goldenFile}`);
119-
return 1;
120-
}
121-
} else {
122-
// No golden file exists
110+
if (goldenFile === undefined) {
123111
if (approve) {
124112
Log.error(
125113
`x Cannot approve circular depdencies within this repository as no golden file exists.`,
@@ -135,6 +123,17 @@ export function main(
135123
return 0;
136124
}
137125

126+
if (approve) {
127+
writeFileSync(goldenFile, JSON.stringify(actual, null, 2));
128+
Log.info(green('✔ Updated golden file.'));
129+
return 0;
130+
}
131+
132+
if (!existsSync(goldenFile)) {
133+
Log.error(`x Could not find golden file: ${goldenFile}`);
134+
return 1;
135+
}
136+
138137
const expected = goldenFile ? (JSON.parse(readFileSync(goldenFile, 'utf8')) as Golden) : [];
139138
const {fixedCircularDeps, newCircularDeps} = compareGoldens(actual, expected);
140139
const isMatching = fixedCircularDeps.length === 0 && newCircularDeps.length === 0;

0 commit comments

Comments
 (0)