0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

fix: use correct datastore location in test environment (#12640)

This commit is contained in:
Matt Kane 2024-12-05 11:25:49 +00:00 committed by GitHub
parent 8a551c1272
commit 22e405a044
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 5 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes a bug that caused content collections to be returned empty when run in a test environment

View file

@ -50,14 +50,12 @@ export function astroContentVirtualModPlugin({
settings,
fs,
}: AstroContentVirtualModPluginParams): Plugin {
let IS_DEV = false;
let dataStoreFile: URL;
return {
name: 'astro-content-virtual-mod-plugin',
enforce: 'pre',
configResolved(config) {
IS_DEV = !config.isProduction;
dataStoreFile = getDataStoreFile(settings, IS_DEV);
config(_, env) {
dataStoreFile = getDataStoreFile(settings, env.command === 'serve');
},
async resolveId(id) {
if (id === VIRTUAL_MODULE_ID) {

View file

@ -107,7 +107,7 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise<DevS
let store: MutableDataStore | undefined;
try {
const dataStoreFile = getDataStoreFile(restart.container.settings);
const dataStoreFile = getDataStoreFile(restart.container.settings, true);
if (existsSync(dataStoreFile)) {
store = await MutableDataStore.fromFile(dataStoreFile);
}