Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run sync as part of astro check #5823

Merged
merged 5 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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