Skip to content

Commit 4232096

Browse files
authored
Give helpful hint if you pass a bad directory when deploying (#2013)
1 parent 73f363f commit 4232096

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.changeset/wet-steaks-reflect.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
If you pass a directory when calling deploy we validate it exists and give helpful hints

packages/cli-v3/src/commands/deploy.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { spinner } from "../utilities/windows.js";
3434
import { login } from "./login.js";
3535
import { updateTriggerPackages } from "./update.js";
3636
import { setGithubActionsOutputAndEnvVars } from "../utilities/githubActions.js";
37+
import { isDirectory } from "../utilities/fileSystem.js";
3738

3839
const DeployCommandOptions = CommonCommandOptions.extend({
3940
dryRun: z.boolean().default(false),
@@ -168,7 +169,24 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
168169
await updateTriggerPackages(dir, { ...options }, true, true);
169170
}
170171

171-
const projectPath = resolve(process.cwd(), dir);
172+
const cwd = process.cwd();
173+
const projectPath = resolve(cwd, dir);
174+
175+
if (dir !== "." && !isDirectory(projectPath)) {
176+
if (dir === "staging" || dir === "prod") {
177+
throw new Error(`To deploy to ${dir}, you need to pass "--env ${dir}", not just "${dir}".`);
178+
}
179+
180+
if (dir === "production") {
181+
throw new Error(`To deploy to production, you need to pass "--env prod", not "production".`);
182+
}
183+
184+
if (dir === "stg") {
185+
throw new Error(`To deploy to staging, you need to pass "--env staging", not "stg".`);
186+
}
187+
188+
throw new Error(`Directory "${dir}" not found at ${projectPath}`);
189+
}
172190

173191
const authorization = await login({
174192
embedded: true,

0 commit comments

Comments
 (0)