mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +00:00
fix(kit): ensure directory exists before writing virtual template (#1473)
This commit is contained in:
parent
46f858dd82
commit
a0da91839a
@ -2,6 +2,7 @@ import { promises as fsp } from 'fs'
|
|||||||
import defu from 'defu'
|
import defu from 'defu'
|
||||||
import { applyDefaults } from 'untyped'
|
import { applyDefaults } from 'untyped'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
|
import { dirname } from 'pathe'
|
||||||
import { useNuxt, nuxtCtx } from '../nuxt'
|
import { useNuxt, nuxtCtx } from '../nuxt'
|
||||||
import type { Nuxt, NuxtTemplate } from '../types/nuxt'
|
import type { Nuxt, NuxtTemplate } from '../types/nuxt'
|
||||||
import type { NuxtModule, LegacyNuxtModule, ModuleOptions } from '../types/module'
|
import type { NuxtModule, LegacyNuxtModule, ModuleOptions } from '../types/module'
|
||||||
@ -89,6 +90,7 @@ export function defineNuxtModule<OptionsT extends ModuleOptions> (input: NuxtMod
|
|||||||
}
|
}
|
||||||
for await (const template of virtualTemplates) {
|
for await (const template of virtualTemplates) {
|
||||||
const contents = await compileTemplate({ ...template, src: '' }, context)
|
const contents = await compileTemplate({ ...template, src: '' }, context)
|
||||||
|
await fsp.mkdir(dirname(template.dst), { recursive: true })
|
||||||
await fsp.writeFile(template.dst, contents)
|
await fsp.writeFile(template.dst, contents)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user