Skip to content

Commit

Permalink
Fix examples check hang (#7998)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Aug 9, 2023
1 parent 0f637c7 commit 65c3549
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-deers-yawn.md
@@ -0,0 +1,5 @@
---
'astro': patch
---

Call `astro sync` once before calling `astro check`
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -76,6 +76,7 @@
"astro-benchmark": "workspace:*"
},
"devDependencies": {
"@astrojs/check": "^0.1.0",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.1",
"@types/node": "^18.16.18",
Expand Down
12 changes: 11 additions & 1 deletion packages/astro/src/cli/check/index.ts
@@ -1,7 +1,7 @@
import path from 'node:path';
import type { Arguments } from 'yargs-parser';
import { error, info } from '../../core/logger/core.js';
import { createLoggingFromFlags } from '../flags.js';
import { createLoggingFromFlags, flagsToAstroInlineConfig } from '../flags.js';
import { getPackage } from '../install-package.js';

export async function check(flags: Arguments) {
Expand All @@ -24,6 +24,16 @@ export async function check(flags: Arguments) {
return;
}

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

const { check: checker, parseArgsAsCheckConfig } = checkPackage;

const config = parseArgsAsCheckConfig(process.argv);
Expand Down
7 changes: 3 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 65c3549

Please sign in to comment.