Skip to content

Commit

Permalink
use module types
Browse files Browse the repository at this point in the history
Signed-off-by: Francis <colifran@amazon.com>
  • Loading branch information
colifran committed May 11, 2024
1 parent e1e3444 commit ac06e69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
SuperInitializer,
Expression,
ClassSpec,
$T,
} from '@cdklabs/typewriter';
import { Runtime } from './config';
import { HandlerFrameworkModule } from './framework';
Expand Down Expand Up @@ -97,7 +98,9 @@ export abstract class HandlerFrameworkClass extends ClassType {

const superProps = new ObjectLiteral([
new Splat(expr.ident('props')),
['code', expr.directCode(`lambda.Code.fromAsset(path.join(__dirname, '${props.codeDirectory}'))`)],
['code', $T(LAMBDA_MODULE.Code).fromAsset(
PATH_MODULE.join.expr.call(expr.directCode(`__dirname, '${props.codeDirectory}'`)),
)],
['handler', expr.lit(props.handler)],
['runtime', this.buildRuntimeProperty(scope, props.runtime)],
]);
Expand Down Expand Up @@ -157,7 +160,9 @@ export abstract class HandlerFrameworkClass extends ClassType {

const superProps = new ObjectLiteral([
new Splat(expr.ident('props')),
['code', expr.directCode(`lambda.Code.fromAsset(path.join(__dirname, '${props.codeDirectory}'))`)],
['code', $T(LAMBDA_MODULE.Code).fromAsset(
PATH_MODULE.join.expr.call(expr.directCode(`__dirname, '${props.codeDirectory}'`)),
)],
['handler', expr.lit(props.handler)],
['runtime', this.buildRuntimeProperty(scope, props.runtime)],
]);
Expand Down Expand Up @@ -256,7 +261,7 @@ export abstract class HandlerFrameworkClass extends ClassType {

const superProps = new ObjectLiteral([
new Splat(expr.ident('props')),
['codeDirectory', expr.directCode(`path.join(__dirname, '${props.codeDirectory}')`)],
['codeDirectory', PATH_MODULE.join.expr.call(expr.directCode(`__dirname, '${props.codeDirectory}'`))],
['runtimeName', this.buildRuntimeProperty(scope, props.runtime, true)],
]);
this.buildConstructor({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export abstract class ImportableModule extends ExternalModule {
}

class PathModule extends ImportableModule {
public readonly join = makeCallableExpr(this, 'join');

public readonly importAs = 'path';

public constructor() {
Expand Down Expand Up @@ -43,6 +45,7 @@ class LambdaModule extends ImportableModule {
public readonly FunctionOptions = Type.fromName(this, 'FunctionOptions');
public readonly Runtime = Type.fromName(this, 'Runtime');
public readonly RuntimeFamily = Type.fromName(this, 'RuntimeFamily');
public readonly Code = Type.fromName(this, 'Code');

public readonly determineLatestNodeRuntime = makeCallableExpr(this, 'determineLatestNodeRuntime');

Expand Down

0 comments on commit ac06e69

Please sign in to comment.