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 authored and Caleb ツ Everett committed Jan 19, 2023
1 parent 24d6380 commit 8f7b971
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/ui/node/reporter.ts
@@ -1,4 +1,4 @@
import { existsSync, promises as fs } from 'node:fs'
import { promises as fs } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { basename, dirname, relative, resolve } from 'pathe'
import c from 'picocolors'
Expand Down 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 8f7b971

Please sign in to comment.