Skip to content

Commit

Permalink
Move formatter creation to try block so the formatter is not created …
Browse files Browse the repository at this point in the history
…if it can't write output.
  • Loading branch information
Michael Morris committed Mar 22, 2023
1 parent cf5d171 commit 26212c4
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/api/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@ export async function initializeFormatters({

try {
await mkdirp(path.dirname(absoluteTarget))

const stream: IFormatterStream = fs.createWriteStream(null, {
fd: await fs.open(absoluteTarget, 'w'),
})

formatters.push(await initializeFormatter(stream, target, type))
} catch (error) {
logger.warn('Failed to ensure directory for formatter target exists')
logger.warn(
`Cucumber was unable to create file "${absoluteTarget}". Check the access permissions of the directory. The test will continue from here, but no report file will be generated.`
)
}

const stream: IFormatterStream = fs.createWriteStream(null, {
fd: await fs.open(absoluteTarget, 'w'),
})
formatters.push(await initializeFormatter(stream, target, type))
})(target, type)
)
})
Expand Down

0 comments on commit 26212c4

Please sign in to comment.