|
1 | 1 | #!/usr/bin/env node
|
2 | 2 |
|
3 |
| -import yargs from "yargs"; |
4 |
| -import { hideBin } from "yargs/helpers"; |
5 |
| -import { convertJUnitToCTRFReport } from "./convert.js"; |
| 3 | +import yargs from 'yargs' |
| 4 | +import { hideBin } from 'yargs/helpers' |
| 5 | +import { convertJUnitToCTRFReport } from './convert.js' |
6 | 6 |
|
7 | 7 | void yargs(hideBin(process.argv))
|
8 |
| - .usage("Usage: $0 <junit.xml> [options]") |
| 8 | + .usage('Usage: $0 <junit.xml> [options]') |
9 | 9 | .command(
|
10 |
| - "$0 <pattern>", |
11 |
| - "Convert JUnit XML report(s) to CTRF", |
12 |
| - (yargs) => { |
| 10 | + '$0 <pattern>', |
| 11 | + 'Convert JUnit XML report(s) to CTRF', |
| 12 | + yargs => { |
13 | 13 | return yargs
|
14 |
| - .positional("pattern", { |
| 14 | + .positional('pattern', { |
15 | 15 | describe:
|
16 | 16 | 'Glob pattern to match JUnit XML files (e.g., "test-results/**/*.xml")',
|
17 |
| - type: "string", |
| 17 | + type: 'string', |
18 | 18 | demandOption: true,
|
19 | 19 | })
|
20 |
| - .option("output", { |
21 |
| - alias: "o", |
22 |
| - type: "string", |
23 |
| - default: "ctrf/ctrf-report.json", |
24 |
| - description: "Output directory and filename for the CTRF report", |
| 20 | + .option('output', { |
| 21 | + alias: 'o', |
| 22 | + type: 'string', |
| 23 | + default: 'ctrf/ctrf-report.json', |
| 24 | + description: 'Output directory and filename for the CTRF report', |
25 | 25 | })
|
26 |
| - .option("tool", { |
27 |
| - alias: "t", |
28 |
| - type: "string", |
29 |
| - description: "Tool name", |
| 26 | + .option('tool', { |
| 27 | + alias: 't', |
| 28 | + type: 'string', |
| 29 | + description: 'Tool name', |
30 | 30 | })
|
31 |
| - .option("env", { |
32 |
| - alias: "e", |
33 |
| - type: "array", |
34 |
| - description: "Environment properties", |
| 31 | + .option('env', { |
| 32 | + alias: 'e', |
| 33 | + type: 'array', |
| 34 | + description: 'Environment properties', |
35 | 35 | })
|
36 |
| - .option("use-suite-name", { |
37 |
| - alias: "u", |
38 |
| - type: "boolean", |
| 36 | + .option('use-suite-name', { |
| 37 | + alias: 'u', |
| 38 | + type: 'boolean', |
39 | 39 | default: true,
|
40 |
| - description: "Use suite name in the test name", |
41 |
| - }); |
| 40 | + description: 'Use suite name in the test name', |
| 41 | + }) |
42 | 42 | },
|
43 |
| - async (argv) => { |
| 43 | + async argv => { |
44 | 44 | try {
|
45 |
| - const { pattern, output, tool, env, useSuiteName } = argv; |
| 45 | + const { pattern, output, tool, env, useSuiteName } = argv |
46 | 46 | await convertJUnitToCTRFReport(pattern as string, {
|
47 | 47 | outputPath: output as string,
|
48 | 48 | toolName: tool as string,
|
49 | 49 | envProps: env as string[],
|
50 | 50 | useSuiteName: useSuiteName as boolean,
|
51 | 51 | log: true,
|
52 |
| - }); |
53 |
| - console.log("Conversion completed successfully."); |
| 52 | + }) |
| 53 | + console.log('Conversion completed successfully.') |
54 | 54 | } catch (error: unknown) {
|
55 |
| - const message = error instanceof Error ? error.message : String(error); |
56 |
| - console.error("Error:", message); |
| 55 | + const message = error instanceof Error ? error.message : String(error) |
| 56 | + console.error('Error:', message) |
57 | 57 | }
|
58 |
| - }, |
| 58 | + } |
59 | 59 | )
|
60 |
| - .help().argv; |
| 60 | + .help().argv |
0 commit comments