diff --git a/scripts/task.ts b/scripts/task.ts index 01cc2e48a8ce..183f9bfd48d6 100644 --- a/scripts/task.ts +++ b/scripts/task.ts @@ -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 {