tasks: skip writing junit no failure if it has already been reported

This commit is contained in:
Yann Braga 2022-11-08 11:53:27 +01:00
parent 4fdc8317a0
commit 28e8c4ed1d

View File

@ -1,5 +1,5 @@
/* eslint-disable no-await-in-loop */
import { AbortController } from 'node-abort-controller';
import type { AbortController } from 'node-abort-controller';
import { getJunitXml } from 'junit-xml';
import { outputFile, existsSync, readFile } from 'fs-extra';
import { join, resolve } from 'path';
@ -7,7 +7,8 @@ import { prompt } from 'prompts';
import boxen from 'boxen';
import { dedent } from 'ts-dedent';
import { createOptions, getCommand, getOptionsOrPrompt, OptionValues } from './utils/options';
import type { OptionValues } from './utils/options';
import { createOptions, getCommand, getOptionsOrPrompt } from './utils/options';
import { install } from './tasks/install';
import { compile } from './tasks/compile';
import { check } from './tasks/check';
@ -278,7 +279,10 @@ async function runTask(task: Task, details: TemplateDetails, optionValues: Passe
return controller;
} catch (err) {
if (junitFilename) await writeJunitXml(getTaskKey(task), details.key, startTime, err);
// If there's a non-test related error (junit report has not been reported already), we report the general failure in a junit report
if (junitFilename && !existsSync(junitFilename)) {
await writeJunitXml(getTaskKey(task), details.key, startTime, err);
}
throw err;
} finally {