Skip to content

Commit 27376df

Browse files
authored
fix(cli): show a useful error message when config file is missing (#2650)
* fix(cli): show a useful error message when config file is missing * Add changeset
1 parent e0cece7 commit 27376df

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

.changeset/warm-eagles-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Fixed misleading error message in the CLI when config file is missing ("maxDuration" is now required). A useful error message is now shown, including a hint about the `--config` flag.

packages/cli-v3/src/config.ts

Lines changed: 16 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,21 @@ 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+
throw 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+
}
180+
165181
const config =
166182
"config" in result.config ? (result.config.config as TriggerConfig) : result.config;
167183

0 commit comments

Comments
 (0)