diff --git a/.changeset/real-nails-clean.md b/.changeset/real-nails-clean.md new file mode 100644 index 000000000..9748a82ad --- /dev/null +++ b/.changeset/real-nails-clean.md @@ -0,0 +1,5 @@ +--- +'astro': minor +--- + +Generate content types when running `astro check` diff --git a/packages/astro/src/cli/check/index.ts b/packages/astro/src/cli/check/index.ts index b5e152abd..037525a5b 100644 --- a/packages/astro/src/cli/check/index.ts +++ b/packages/astro/src/cli/check/index.ts @@ -1,6 +1,7 @@ /* eslint-disable no-console */ import { AstroCheck, DiagnosticSeverity } from '@astrojs/language-server'; import type { AstroSettings } from '../../@types/astro'; +import type { LogOptions } from '../../core/logger/core.js'; import glob from 'fast-glob'; import * as fs from 'fs'; @@ -17,9 +18,14 @@ interface Result { hints: number; } -export async function check(settings: AstroSettings) { +export async function check(settings: AstroSettings, { logging }: { logging: LogOptions }) { console.log(bold('astro check')); + const { sync } = await import('../sync/index.js'); + const syncRet = await sync(settings, { logging, fs }); + // early exit on sync failure + if (syncRet === 1) return syncRet; + const root = settings.config.root; const spinner = ora(` Getting diagnostics for Astro files in ${fileURLToPath(root)}…`).start(); diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index d44421e06..a1f5a54f8 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -206,7 +206,7 @@ async function runCommand(cmd: string, flags: yargs.Arguments) { } case 'check': { - const ret = await check(settings); + const ret = await check(settings, { logging }); return process.exit(ret); }