From 1f49cddf9e9ffc651efc171b2cbde9fbe9e8709d Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Wed, 11 Jan 2023 17:57:41 +0100 Subject: [PATCH] Run sync as part of `astro check` (#5823) Co-authored-by: Ben Holmes --- .changeset/real-nails-clean.md | 5 +++++ packages/astro/src/cli/check/index.ts | 8 +++++++- packages/astro/src/cli/index.ts | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changeset/real-nails-clean.md 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); }