Run sync as part of astro check
(#5823)
Co-authored-by: Ben Holmes <hey@bholmes.dev>
This commit is contained in:
parent
982e21c164
commit
1f49cddf9e
3 changed files with 13 additions and 2 deletions
5
.changeset/real-nails-clean.md
Normal file
5
.changeset/real-nails-clean.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Generate content types when running `astro check`
|
|
@ -1,6 +1,7 @@
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import { AstroCheck, DiagnosticSeverity } from '@astrojs/language-server';
|
import { AstroCheck, DiagnosticSeverity } from '@astrojs/language-server';
|
||||||
import type { AstroSettings } from '../../@types/astro';
|
import type { AstroSettings } from '../../@types/astro';
|
||||||
|
import type { LogOptions } from '../../core/logger/core.js';
|
||||||
|
|
||||||
import glob from 'fast-glob';
|
import glob from 'fast-glob';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
@ -17,9 +18,14 @@ interface Result {
|
||||||
hints: number;
|
hints: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function check(settings: AstroSettings) {
|
export async function check(settings: AstroSettings, { logging }: { logging: LogOptions }) {
|
||||||
console.log(bold('astro check'));
|
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 root = settings.config.root;
|
||||||
|
|
||||||
const spinner = ora(` Getting diagnostics for Astro files in ${fileURLToPath(root)}…`).start();
|
const spinner = ora(` Getting diagnostics for Astro files in ${fileURLToPath(root)}…`).start();
|
||||||
|
|
|
@ -206,7 +206,7 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'check': {
|
case 'check': {
|
||||||
const ret = await check(settings);
|
const ret = await check(settings, { logging });
|
||||||
return process.exit(ret);
|
return process.exit(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue