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:
parent
8a551c1272
commit
22e405a044
3 changed files with 8 additions and 5 deletions
5
.changeset/violet-bugs-enjoy.md
Normal file
5
.changeset/violet-bugs-enjoy.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes a bug that caused content collections to be returned empty when run in a test environment
|
|
@ -50,14 +50,12 @@ export function astroContentVirtualModPlugin({
|
||||||
settings,
|
settings,
|
||||||
fs,
|
fs,
|
||||||
}: AstroContentVirtualModPluginParams): Plugin {
|
}: AstroContentVirtualModPluginParams): Plugin {
|
||||||
let IS_DEV = false;
|
|
||||||
let dataStoreFile: URL;
|
let dataStoreFile: URL;
|
||||||
return {
|
return {
|
||||||
name: 'astro-content-virtual-mod-plugin',
|
name: 'astro-content-virtual-mod-plugin',
|
||||||
enforce: 'pre',
|
enforce: 'pre',
|
||||||
configResolved(config) {
|
config(_, env) {
|
||||||
IS_DEV = !config.isProduction;
|
dataStoreFile = getDataStoreFile(settings, env.command === 'serve');
|
||||||
dataStoreFile = getDataStoreFile(settings, IS_DEV);
|
|
||||||
},
|
},
|
||||||
async resolveId(id) {
|
async resolveId(id) {
|
||||||
if (id === VIRTUAL_MODULE_ID) {
|
if (id === VIRTUAL_MODULE_ID) {
|
||||||
|
|
|
@ -107,7 +107,7 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise<DevS
|
||||||
|
|
||||||
let store: MutableDataStore | undefined;
|
let store: MutableDataStore | undefined;
|
||||||
try {
|
try {
|
||||||
const dataStoreFile = getDataStoreFile(restart.container.settings);
|
const dataStoreFile = getDataStoreFile(restart.container.settings, true);
|
||||||
if (existsSync(dataStoreFile)) {
|
if (existsSync(dataStoreFile)) {
|
||||||
store = await MutableDataStore.fromFile(dataStoreFile);
|
store = await MutableDataStore.fromFile(dataStoreFile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue