Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 26099a1

Browse files
committed
🐛 fix(cdk envs): pass env variables to CDK commands so it's accepted on Windows as valid syntax
1 parent 0985e6f commit 26099a1

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

Diff for: lib/cli/deploy.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,24 @@ export const deployHandler = async ({ stackName, appPath, bootstrap, lambdaMemor
1616
// All paths are absolute.
1717
const cdkApp = `node ${appPath}`
1818
const cdkCiFlags = `--require-approval never --ci`
19-
const envConfig = [
20-
`STACK_NAME=${stackName}`,
21-
lambdaMemory ? `LAMBDA_MEMORY=${lambdaMemory}` : '',
22-
lambdaTimeout ? `LAMBDA_TIMEOUT=${lambdaTimeout}` : '',
23-
hostedZone ? `HOSTED_ZONE=${hostedZone}` : '',
24-
domainNamePrefix ? `DNS_PREFIX=${domainNamePrefix}` : '',
25-
].join(' ')
19+
20+
const variables = {
21+
STACK_NAME: stackName,
22+
...(lambdaMemory && { LAMBDA_MEMORY: lambdaMemory.toString() }),
23+
...(lambdaTimeout && { LAMBDA_TIMEOUT: lambdaTimeout.toString() }),
24+
...(hostedZone && { HOSTED_ZONE: hostedZone }),
25+
...(domainNamePrefix && { DNS_PREFIX: domainNamePrefix }),
26+
}
2627

2728
if (bootstrap) {
2829
await executeAsyncCmd({
29-
cmd: `${envConfig} ${cdkExecutable} bootstrap --app "${cdkApp}"`,
30+
cmd: `${cdkExecutable} bootstrap --app "${cdkApp}"`,
31+
env: variables,
3032
})
3133
}
3234

3335
await executeAsyncCmd({
34-
cmd: `${envConfig} ${cdkExecutable} deploy --app "${cdkApp}" ${cdkCiFlags}`,
36+
cmd: `${cdkExecutable} deploy --app "${cdkApp}" ${cdkCiFlags}`,
37+
env: variables,
3538
})
3639
}

Diff for: lib/utils.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,16 @@ export const zipMultipleFoldersOrFiles = async ({ outputName, inputDefinition }:
7979
interface CommandProps {
8080
cmd: string
8181
path?: string
82+
env?: Record<string, string>
8283
}
8384

84-
export const executeAsyncCmd = async ({ cmd, path }: CommandProps) => {
85+
export const executeAsyncCmd = async ({ cmd, path, env }: CommandProps) => {
8586
if (path) {
8687
process.chdir(path)
8788
}
8889

8990
return new Promise((resolve, reject) => {
90-
const sh = exec(cmd, (error, stdout, stderr) => {
91+
const sh = exec(cmd, { env: { ...process.env, ...env } }, (error, stdout, stderr) => {
9192
if (error) {
9293
reject(error)
9394
} else {

Diff for: package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)