Skip to content

Commit b223a5e

Browse files
committed
fix(cli): show a useful error message when config file is missing
1 parent e0cece7 commit b223a5e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/cli-v3/src/config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
import { prettyWarning } from "./utilities/cliOutput.js";
2323
import type { InstrumentationModuleDefinition } from "@opentelemetry/instrumentation";
2424
import { builtinModules } from "node:module";
25+
import { OutroCommandError } from "./cli/common.js";
2526

2627
export type ResolveConfigOptions = {
2728
cwd?: string;
@@ -162,6 +163,23 @@ async function resolveConfig(
162163
? dirname(packageJsonPath)
163164
: cwd;
164165

166+
// `trigger.config` is the fallback value set by c12
167+
const missingConfigFile = !result.configFile || result.configFile === "trigger.config";
168+
169+
if (missingConfigFile) {
170+
const err = new OutroCommandError(
171+
[
172+
"Couldn't find your trigger.config.ts file.",
173+
"",
174+
"Make sure you are in the directory of your Trigger.dev project, or specify the path to your config file using the `--config <path>` flag.",
175+
"",
176+
"Alternatively, you can initialize a new project using `npx trigger.dev@latest init`.",
177+
].join("\n")
178+
);
179+
err.stack = undefined;
180+
throw err;
181+
}
182+
165183
const config =
166184
"config" in result.config ? (result.config.config as TriggerConfig) : result.config;
167185

0 commit comments

Comments
 (0)