Skip to content

Commit

Permalink
fix: use correct datastore location in test environment (withastro#12640
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ascorbic authored Dec 5, 2024
1 parent 8a551c1 commit 22e405a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-bugs-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a bug that caused content collections to be returned empty when run in a test environment
6 changes: 2 additions & 4 deletions packages/astro/src/content/vite-plugin-content-virtual-mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 22e405a

Please sign in to comment.