Skip to content

Commit

Permalink
Run sync as part of astro check (#5823)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Holmes <hey@bholmes.dev>
  • Loading branch information
delucis and bholmesdev authored Jan 11, 2023
1 parent 982e21c commit 1f49cdd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-nails-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': minor
---

Generate content types when running `astro check`
8 changes: 7 additions & 1 deletion packages/astro/src/cli/check/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 1f49cdd

Please sign in to comment.