Skip to content

Commit 65c3549

Browse files
authored
Fix examples check hang (#7998)
1 parent 0f637c7 commit 65c3549

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

.changeset/gentle-deers-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Call `astro sync` once before calling `astro check`

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"astro-benchmark": "workspace:*"
7777
},
7878
"devDependencies": {
79+
"@astrojs/check": "^0.1.0",
7980
"@changesets/changelog-github": "^0.4.8",
8081
"@changesets/cli": "^2.26.1",
8182
"@types/node": "^18.16.18",

packages/astro/src/cli/check/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path';
22
import type { Arguments } from 'yargs-parser';
33
import { error, info } from '../../core/logger/core.js';
4-
import { createLoggingFromFlags } from '../flags.js';
4+
import { createLoggingFromFlags, flagsToAstroInlineConfig } from '../flags.js';
55
import { getPackage } from '../install-package.js';
66

77
export async function check(flags: Arguments) {
@@ -24,6 +24,16 @@ export async function check(flags: Arguments) {
2424
return;
2525
}
2626

27+
// Run sync before check to make sure types are generated.
28+
// NOTE: In the future, `@astrojs/check` can expose a `before lint` hook so that this works during `astro check --watch` too.
29+
// For now, we run this once as usually `astro check --watch` is ran alongside `astro dev` which also calls `astro sync`.
30+
const { sync } = await import('../../core/sync/index.js');
31+
const inlineConfig = flagsToAstroInlineConfig(flags);
32+
const exitCode = await sync(inlineConfig);
33+
if (exitCode !== 0) {
34+
process.exit(exitCode);
35+
}
36+
2737
const { check: checker, parseArgsAsCheckConfig } = checkPackage;
2838

2939
const config = parseArgsAsCheckConfig(process.argv);

pnpm-lock.yaml

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)