From 4b86514abae7a69f7e913cb44661b5556af5c748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Mon, 2 Jul 2018 11:45:09 +0200 Subject: [PATCH] Some fixes --- packages/@aws-cdk/lambda/lib/runtime.ts | 28 +++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/@aws-cdk/lambda/lib/runtime.ts b/packages/@aws-cdk/lambda/lib/runtime.ts index 860e6f4899ec1..7f83590606d68 100644 --- a/packages/@aws-cdk/lambda/lib/runtime.ts +++ b/packages/@aws-cdk/lambda/lib/runtime.ts @@ -1,19 +1,27 @@ +export interface LambdaRuntimeProps { + /** + * Whether the ``ZipFile`` (aka inline code) property can be used with this runtime. + * @default false + */ + readonly supportsInlineCode?: boolean; +} + /** * Lambda function runtime environment. */ export class LambdaRuntime { - public static readonly NodeJS = new LambdaRuntime('nodejs', true) as InlinableJavascriptLambdaRuntime; + public static readonly NodeJS = new LambdaRuntime('nodejs', { supportsInlineCode: true }) as InlinableJavascriptLambdaRuntime; // Using ``as InlinableLambdaRuntime`` because that calss cannot be defined just yet - public static readonly NodeJS43 = new LambdaRuntime('nodejs4.3', true) as InlinableJavascriptLambdaRuntime; + public static readonly NodeJS43 = new LambdaRuntime('nodejs4.3', { supportsInlineCode: true }) as InlinableJavascriptLambdaRuntime; public static readonly NodeJS43Edge = new LambdaRuntime('nodejs4.3-edge'); // Using ``as InlinableLambdaRuntime`` because that calss cannot be defined just yet - public static readonly NodeJS610 = new LambdaRuntime('nodejs6.10', true) as InlinableJavascriptLambdaRuntime; + public static readonly NodeJS610 = new LambdaRuntime('nodejs6.10', { supportsInlineCode: true }) as InlinableJavascriptLambdaRuntime; public static readonly NodeJS810 = new LambdaRuntime('nodejs8.10'); public static readonly Java8 = new LambdaRuntime('java8'); // Using ``as InlinableLambdaRuntime`` because that calss cannot be defined just yet - public static readonly Python27 = new LambdaRuntime('python2.7', true) as InlinableLambdaRuntime; + public static readonly Python27 = new LambdaRuntime('python2.7', { supportsInlineCode: true }) as InlinableLambdaRuntime; // Using ``as InlinableLambdaRuntime`` because that calss cannot be defined just yet - public static readonly Python36 = new LambdaRuntime('python3.6', true) as InlinableLambdaRuntime; + public static readonly Python36 = new LambdaRuntime('python3.6', { supportsInlineCode: true }) as InlinableLambdaRuntime; public static readonly DotNetCore1 = new LambdaRuntime('dotnetcore1.0'); public static readonly DotNetCore2 = new LambdaRuntime('dotnetcore2.0'); public static readonly Go1x = new LambdaRuntime('go1.x'); @@ -23,9 +31,9 @@ export class LambdaRuntime { /** Whether the ``ZipFile`` (aka inline code) property can be used with this runtime. */ public readonly supportsInlineCode: boolean; - constructor(name: string, supportsInlineCode: boolean = false) { + constructor(name: string, props: LambdaRuntimeProps = {}) { this.name = name; - this.supportsInlineCode = supportsInlineCode; + this.supportsInlineCode = !!props.supportsInlineCode; } public toString(): string { @@ -45,7 +53,5 @@ export interface InlinableLambdaRuntime { /** * A ``LambdaRuntime`` that can be used for inlining JavaScript. */ -export interface InlinableJavascriptLambdaRuntime extends InlinableLambdaRuntime { - readonly name: string; - readonly supportsInlineCode: true; -} +// tslint:disable-next-line:no-empty-interface this is a marker to allow type-safe declarations +export interface InlinableJavascriptLambdaRuntime extends InlinableLambdaRuntime {}