@@ -55,11 +55,7 @@ async function writeParseOutput(args: {
5555 console . error (
5656 `✓ Successfully parsed and wrote file-store output to: ${ resolvedOutputDir } ` ,
5757 ) ;
58-
59- return ;
60- }
61-
62- if ( output ) {
58+ } else if ( output ) {
6359 const resolvedOutput = resolveCliPath ( output ) ;
6460
6561 // eslint-disable-next-line security/detect-non-literal-fs-filename
@@ -68,12 +64,7 @@ async function writeParseOutput(args: {
6864 console . error (
6965 `✓ Successfully parsed and wrote output to: ${ resolvedOutput } ` ,
7066 ) ;
71-
72- return ;
7367 }
74-
75- // eslint-disable-next-line no-console
76- console . log ( jsonOutput ) ;
7768}
7869
7970function reportMappingValidation (
@@ -117,7 +108,7 @@ async function parseArguments(): Promise<Arguments> {
117108 . option ( "output" , {
118109 alias : "o" ,
119110 type : "string" ,
120- description : "Write output to a file instead of stdout " ,
111+ description : "Write output to a file" ,
121112 } )
122113 . option ( "output-dir" , {
123114 alias : "d" ,
@@ -168,22 +159,24 @@ async function runParser({
168159 assertValidInputFile ( resolvedInput ) ;
169160
170161 const result = parseExcelFile ( resolvedInput ) ;
171- const mappingValidation = checkMappings
172- ? validateIncompleteMappings ( result )
173- : undefined ;
174162 const jsonOutput = stringifyJsonWithSortedKeys (
175163 result ,
176164 pretty ? 2 : undefined ,
177165 ) ;
178166
179- await writeParseOutput ( {
180- jsonOutput,
181- output,
182- outputDir,
183- pretty,
184- result,
185- } ) ;
186- reportMappingValidation ( mappingValidation ) ;
167+ if ( output || outputDir ) {
168+ await writeParseOutput ( {
169+ jsonOutput,
170+ output,
171+ outputDir,
172+ pretty,
173+ result,
174+ } ) ;
175+ }
176+
177+ if ( checkMappings ) {
178+ reportMappingValidation ( validateIncompleteMappings ( result ) ) ;
179+ }
187180}
188181
189182async function main ( ) : Promise < void > {
0 commit comments