summaryrefslogtreecommitdiff
path: root/src/cli.ts
diff options
context:
space:
mode:
authorGravatar Drew Powers <1369770+drwpow@users.noreply.github.com> 2021-04-05 15:56:46 -0600
committerGravatar GitHub <noreply@github.com> 2021-04-05 15:56:46 -0600
commit1acd5ee310040d654f6d457a1dd53b9cb19f1f51 (patch)
tree86d46a87817d70f7b7c7aa18ce9e30a98a27ee98 /src/cli.ts
parent71e5de76f136a0ef76253c05bb8072898bcf08f7 (diff)
downloadastro-1acd5ee310040d654f6d457a1dd53b9cb19f1f51.tar.gz
astro-1acd5ee310040d654f6d457a1dd53b9cb19f1f51.tar.zst
astro-1acd5ee310040d654f6d457a1dd53b9cb19f1f51.zip
Allow no config (#61)
* Allow no config * Update README
Diffstat (limited to 'src/cli.ts')
-rw-r--r--src/cli.ts11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/cli.ts b/src/cli.ts
index e0f0c0dc3..71c9691d7 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -58,14 +58,13 @@ async function printVersion() {
/** Handle `astro run` command */
async function runCommand(rawRoot: string, cmd: (a: AstroConfig) => Promise<void>) {
- const astroConfig = await loadConfig(rawRoot);
- if (typeof astroConfig === 'undefined') {
- console.error(colors.red(' An astro.config.mjs file is required.\n'));
- printHelp();
+ try {
+ const astroConfig = await loadConfig(rawRoot);
+ return cmd(astroConfig);
+ } catch (err) {
+ console.error(colors.red(err.toString() || err));
process.exit(1);
}
-
- return cmd(astroConfig);
}
const cmdMap = new Map([