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,
|
||||
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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue