Skip to content

Commit 4830e1c

Browse files
committed
fix(env): mkdir the envFile's parent dir and throw on upload failure
For nested envFile paths (e.g. apps/backend/.env.production in a monorepo workspace) \`mkdir -p \${appPath}/shared\` isn't enough — the \`echo|base64 -d > \${sharedEnv}\` redirect silently fails because the parent directory doesn't exist. The CLI still printed "Uploaded to ..." because executor.exec doesn't check exit codes, and the symlink was created pointing at a non-existent file, causing the next deploy to break with an obscure ./.env sourcing error. Switch to execOrThrow on each step and mkdir the actual parent of sharedEnv via dirname.
1 parent 44f86fe commit 4830e1c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/cli/commands/env.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ export async function cmdEnv(
3232
const appPath = `${config.remotePath}/${app.name}`;
3333
const sharedEnv = `${appPath}/shared/${app.envFile}`;
3434
const sharedEnvAlias = `${appPath}/shared/.env`;
35-
await executor.exec(`mkdir -p "${appPath}/shared"`);
36-
await executor.exec(`echo "${b64}" | base64 -d > "${sharedEnv}"`);
37-
await executor.exec(`chmod 600 "${sharedEnv}"`);
35+
// Ensure the parent dir of sharedEnv exists — when envFile is nested
36+
// (e.g. apps/backend/.env.production) `mkdir -p shared` isn't enough
37+
// and the base64 redirect below fails silently.
38+
await executor.execOrThrow(`mkdir -p "$(dirname "${sharedEnv}")"`);
39+
await executor.execOrThrow(`echo "${b64}" | base64 -d > "${sharedEnv}"`);
40+
await executor.execOrThrow(`chmod 600 "${sharedEnv}"`);
3841
if (app.envFile !== '.env') {
39-
await executor.exec(`ln -sf "${sharedEnv}" "${sharedEnvAlias}"`);
42+
await executor.execOrThrow(`ln -sf "${sharedEnv}" "${sharedEnvAlias}"`);
4043
}
4144
ui.success(`Uploaded to ${sharedEnv}`);
4245

0 commit comments

Comments
 (0)