Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move formatter creation to try block so the formatter is not created …
…if it can't write output.
  • Loading branch information
Michael Morris committed Mar 22, 2023
commit 26212c4c57841d65cf5359ce06e6e63538c8cdf7
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