Skip to content

Commit

Permalink
fix: custom extractor warnings optional (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 authored Sep 23, 2024
1 parent 2e30591 commit ffa66da
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/commands/extract/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const lintHandler = (config: Schema) =>
let warningCount = 0;
let filesCount = 0;
for (const [file, { warnings }] of extracted) {
if (warnings.length) {
if (warnings?.length) {
warningCount += warnings.length;
filesCount++;

Expand Down
4 changes: 2 additions & 2 deletions src/commands/extract/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const printHandler = (config: Schema) =>
}
}

if (warnings.length) {
if (warnings?.length) {
warningCount += warnings.length;
console.log(
'%d warning%s %s emitted during extraction:',
Expand All @@ -60,7 +60,7 @@ const printHandler = (config: Schema) =>
}
}

if (keys.length || warnings.length) {
if (keys.length || warnings?.length) {
console.log();
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/extractor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ export type Extractor = (
options: ExtractOptions
) => ExtractionResult;

export type ExtractionResult = { keys: ExtractedKey[]; warnings: Warning[] };
export type ExtractionResult = { keys: ExtractedKey[]; warnings?: Warning[] };

export type ExtractionResults = Map<
string,
{ keys: ExtractedKey[]; warnings: Warning[] }
>;
export type ExtractionResults = Map<string, ExtractionResult>;
2 changes: 1 addition & 1 deletion src/extractor/warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function dumpWarnings(extractionResult: ExtractionResults) {
let warningCount = 0;

for (const [file, { warnings }] of extractionResult.entries()) {
if (warnings.length) {
if (warnings?.length) {
if (!warningCount) {
console.error('Warnings were emitted during extraction.');
}
Expand Down

0 comments on commit ffa66da

Please sign in to comment.