Skip to content

Commit aae4c4c

Browse files
fix: #111 Prevent initializing Docker in CDK (#113)
1 parent c62deee commit aae4c4c

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/frameworks/cdkFramework.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,14 @@ export class CdkFramework implements IFramework {
326326
// });
327327
global.lambdas.push(lambdaInfo);` + codeToFind,
328328
);
329-
}
330-
331-
if (
329+
} else if (
332330
args.path.includes(
333-
'aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.',
331+
path.join(
332+
'aws-cdk-lib',
333+
'aws-s3-deployment',
334+
'lib',
335+
'bucket-deployment.',
336+
),
334337
)
335338
) {
336339
const codeToFind = 'super(scope,id),this.requestDestinationArn=!1;';
@@ -341,6 +344,24 @@ export class CdkFramework implements IFramework {
341344

342345
// Inject code to prevent deploying the assets
343346
contents = contents.replace(codeToFind, codeToFind + `return;`);
347+
} else if (
348+
args.path.includes(
349+
path.join('aws-cdk-lib', 'aws-lambda-nodejs', 'lib', 'bundling.'),
350+
)
351+
) {
352+
// prevent initializing Docker if esbuild is no installed
353+
// Docker is used for bundling if esbuild is not installed, but it is not needed at this point
354+
const origCode =
355+
'const shouldBuildImage=props.forceDockerBundling||!Bundling.esbuildInstallation;';
356+
const replaceCode = 'const shouldBuildImage=false;';
357+
358+
if (contents.includes(origCode)) {
359+
contents = contents.replace(origCode, replaceCode);
360+
} else {
361+
throw new Error(
362+
`Can not find code to inject in ${args.path} to prevent initializing Docker`,
363+
);
364+
}
344365
}
345366

346367
return {

0 commit comments

Comments
 (0)