Skip to content

Commit

Permalink
Debugging windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Jul 8, 2024
1 parent 616a3cf commit 4a6b453
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -243,4 +243,4 @@
"publishConfig": {
"provenance": true
}
}
}
13 changes: 10 additions & 3 deletions packages/astro/src/content/loaders/glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/test/content-layer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ 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;

before(async () => {
fixture = await loadFixture({ root: './fixtures/content-layer/' });
});

describe('Build', () => {
describe.only('Build', () => {
let json;
before(async () => {
fixture = await loadFixture({ root: './fixtures/content-layer/' });
Expand All @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion scripts/cmd/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 4a6b453

Please sign in to comment.