Skip to content

Commit

Permalink
fix: ENOENT assets when htmldir exists
Browse files Browse the repository at this point in the history
if htmlDir already exists the previous code would not create the assets dir, this can cause ENOENT errors whenever htmlDir exists, but assets does not - for instance when outputing junit and html to the same parent folder

```
vitest --reporter junit html --outputFile.html tests/ --outputFile.junit tests/junit.xml
```

I don't understand why the previous code was checking existsSync before mkdir -p. My best guess is performance, but it's not going to have a significant effect.
  • Loading branch information
everett1992 committed Jan 18, 2023
1 parent 24d6380 commit 16a1f6d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/ui/node/reporter.ts
Expand Up @@ -50,8 +50,7 @@ export default class HTMLReporter implements Reporter {

const metaFile = resolve(htmlDir, 'html.meta.json')

if (!existsSync(htmlDir))
await fs.mkdir(resolve(htmlDir, 'assets'), { recursive: true })
await fs.mkdir(resolve(htmlDir, 'assets'), { recursive: true })

await fs.writeFile(metaFile, report, 'utf-8')
const ui = resolve(distDir, 'client')
Expand Down

0 comments on commit 16a1f6d

Please sign in to comment.