Run sync as part of astro check (#5823)

Co-authored-by: Ben Holmes <hey@bholmes.dev>
This commit is contained in:
Chris Swithinbank 2023-01-11 17:57:41 +01:00 committed by GitHub
parent 982e21c164
commit 1f49cddf9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': minor
---
Generate content types when running `astro check`

View file

@ -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();

View file

@ -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);
}