summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Swithinbank <swithinbank@gmail.com> 2023-01-11 17:57:41 +0100
committerGravatar GitHub <noreply@github.com> 2023-01-11 17:57:41 +0100
commit1f49cddf9e9ffc651efc171b2cbde9fbe9e8709d (patch)
tree0ccb18234cc6a813950abc8fbf652660f95bcafb
parent982e21c164ea1c41efe0eb7d12293ad5783da6bc (diff)
downloadastro-1f49cddf9e9ffc651efc171b2cbde9fbe9e8709d.tar.gz
astro-1f49cddf9e9ffc651efc171b2cbde9fbe9e8709d.tar.zst
astro-1f49cddf9e9ffc651efc171b2cbde9fbe9e8709d.zip
Run sync as part of `astro check` (#5823)
Co-authored-by: Ben Holmes <hey@bholmes.dev>
-rw-r--r--.changeset/real-nails-clean.md5
-rw-r--r--packages/astro/src/cli/check/index.ts8
-rw-r--r--packages/astro/src/cli/index.ts2
3 files changed, 13 insertions, 2 deletions
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);
}