@@ -10,11 +10,11 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
10
10
const messages = Messages . loadMessages ( 'apex-code-coverage-transformer' , 'transformer.transform' ) ;
11
11
12
12
export default class TransformerTransform extends SfCommand < TransformerTransformResult > {
13
- public static readonly summary = messages . getMessage ( 'summary' ) ;
14
- public static readonly description = messages . getMessage ( 'description' ) ;
15
- public static readonly examples = messages . getMessages ( 'examples' ) ;
13
+ public static override readonly summary = messages . getMessage ( 'summary' ) ;
14
+ public static override readonly description = messages . getMessage ( 'description' ) ;
15
+ public static override readonly examples = messages . getMessages ( 'examples' ) ;
16
16
17
- public static readonly flags = {
17
+ public static override readonly flags = {
18
18
'coverage-json' : Flags . file ( {
19
19
summary : messages . getMessage ( 'flags.coverage-json.summary' ) ,
20
20
char : 'j' ,
@@ -44,32 +44,24 @@ export default class TransformerTransform extends SfCommand<TransformerTransform
44
44
45
45
public async run ( ) : Promise < TransformerTransformResult > {
46
46
const { flags } = await this . parse ( TransformerTransform ) ;
47
- const jsonFilePath = flags [ 'coverage-json' ] ;
48
- const outputReportPath = flags [ 'output-report' ] ;
49
- const ignoreDirs = flags [ 'ignore-package-directory' ] ?? [ ] ;
50
- const format = flags [ 'format' ] ;
51
- let finalPath = outputReportPath ;
52
-
53
47
const warnings : string [ ] = [ ] ;
54
48
55
- try {
56
- const result = await transformCoverageReport ( jsonFilePath , outputReportPath , format , ignoreDirs ) ;
57
- warnings . push ( ...result . warnings ) ;
58
- finalPath = result . finalPath ;
59
- } catch ( err ) {
60
- this . error (
61
- 'The provided JSON does not match a known coverage data format from the Salesforce deploy or test command.'
62
- ) ;
63
- }
49
+ const result = await transformCoverageReport (
50
+ flags [ 'coverage-json' ] ,
51
+ flags [ 'output-report' ] ,
52
+ flags [ 'format' ] ,
53
+ flags [ 'ignore-package-directory' ] ?? [ ]
54
+ ) ;
55
+ warnings . push ( ...result . warnings ) ;
56
+ const finalPath = result . finalPath ;
64
57
65
- // Print warnings if any
66
58
if ( warnings . length > 0 ) {
67
59
warnings . forEach ( ( warning ) => {
68
60
this . warn ( warning ) ;
69
61
} ) ;
70
62
}
71
63
72
64
this . log ( `The coverage report has been written to ${ finalPath } ` ) ;
73
- return { path : outputReportPath } ;
65
+ return { path : finalPath } ;
74
66
}
75
67
}
0 commit comments