diff --git a/packages/astro/package.json b/packages/astro/package.json index 32a9d68f5ec31..a0296ecc2b347 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -121,7 +121,7 @@ "test:e2e:match": "playwright test -g", "test:e2e:chrome": "playwright test", "test:e2e:firefox": "playwright test --config playwright.firefox.config.js", - "test:node": "astro-scripts test \"test/**/*.test.js\"" + "test:node": "astro-scripts test \"test/content-layer.test.js\" --timeout 30000 --only" }, "dependencies": { "@astrojs/compiler": "^2.8.1", @@ -243,4 +243,4 @@ "publishConfig": { "provenance": true } -} +} \ No newline at end of file diff --git a/packages/astro/src/content/loaders/glob.ts b/packages/astro/src/content/loaders/glob.ts index cd20973480c9c..836355ece06a2 100644 --- a/packages/astro/src/content/loaders/glob.ts +++ b/packages/astro/src/content/loaders/glob.ts @@ -111,6 +111,9 @@ export function glob(globOptions: GlobOptions): Loader { if (!baseDir.pathname.endsWith('/')) { baseDir.pathname = `${baseDir.pathname}/`; } + console.log('basedir', baseDir); + console.log('globOptions', globOptions.base); + console.log('settings', settings.config.root); const files = await fastGlob(globOptions.pattern, { cwd: fileURLToPath(baseDir), @@ -136,6 +139,10 @@ export function glob(globOptions: GlobOptions): Loader { ) ); + if (!watcher) { + return; + } + const matcher: RegExp = micromatch.makeRe(globOptions.pattern); const matchesGlob = (entry: string) => !entry.startsWith('../') && matcher.test(entry); @@ -152,11 +159,11 @@ export function glob(globOptions: GlobOptions): Loader { await syncData(entry, baseUrl, options, entryType); logger.info(`Reloaded data from ${green(entry)}`); } - watcher?.on('change', onChange); + watcher.on('change', onChange); - watcher?.on('add', onChange); + watcher.on('add', onChange); - watcher?.on('unlink', async (deletedPath) => { + watcher.on('unlink', async (deletedPath) => { const entry = relative(basePath, deletedPath); if (!matchesGlob(entry)) { return; diff --git a/packages/astro/test/content-layer.test.js b/packages/astro/test/content-layer.test.js index 4e1f2d7c3a668..18f8558401e72 100644 --- a/packages/astro/test/content-layer.test.js +++ b/packages/astro/test/content-layer.test.js @@ -4,7 +4,7 @@ import { loadFixture } from './test-utils.js'; import { sep } from 'node:path'; import { sep as posixSep } from 'node:path/posix'; -describe('Content Layer', () => { +describe.only('Content Layer', () => { /** @type {import("./test-utils.js").Fixture} */ let fixture; @@ -12,7 +12,7 @@ describe('Content Layer', () => { fixture = await loadFixture({ root: './fixtures/content-layer/' }); }); - describe('Build', () => { + describe.only('Build', () => { let json; before(async () => { fixture = await loadFixture({ root: './fixtures/content-layer/' }); @@ -21,7 +21,7 @@ describe('Content Layer', () => { json = JSON.parse(rawJson); }); - it('Returns custom loader collection', async () => { + it.only('Returns custom loader collection', async () => { assert.ok(json.hasOwnProperty('customLoader')); assert.ok(Array.isArray(json.customLoader)); diff --git a/packages/astro/test/fixtures/content-layer/src/content/config.ts b/packages/astro/test/fixtures/content-layer/src/content/config.ts index 7b5bd16a9abfd..80807e6ab838a 100644 --- a/packages/astro/test/fixtures/content-layer/src/content/config.ts +++ b/packages/astro/test/fixtures/content-layer/src/content/config.ts @@ -69,8 +69,10 @@ const cats = defineCollection({ }), }); + // Absolute paths should also work -const absoluteRoot = fileURLToPath(new URL('../../content-outside-src', import.meta.url)) +const absoluteRoot = new URL('../../content-outside-src', import.meta.url).href; +console.log('absoluteRoot', absoluteRoot); const spacecraft = defineCollection({ type: 'experimental_data', diff --git a/scripts/cmd/test.js b/scripts/cmd/test.js index 04f02f73afc00..d0d64a883c60a 100644 --- a/scripts/cmd/test.js +++ b/scripts/cmd/test.js @@ -7,7 +7,7 @@ import arg from 'arg'; import glob from 'tiny-glob'; const isCI = !!process.env.CI; -const defaultTimeout = isCI ? 1400000 : 600000; +const defaultTimeout = 600000 //isCI ? 600000 : 600000; export default async function test() { const args = arg({