Skip to content

Commit

Permalink
Add "nodejs14.x" runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Oct 30, 2021
1 parent a2dabe1 commit d95c39f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ implemented are:
* `nodejs8.10` for Node.js Lambda functions using a downloaded Node v8.10.0 binary
* `nodejs10.x` for Node.js Lambda functions using a downloaded Node v10.15.3 binary
* `nodejs12.x` for Node.js Lambda functions using a downloaded Node v12.22.7 binary
* `nodejs14.x` for Node.js Lambda functions using a downloaded Node v14.18.1 binary
* `python` for Python Lambda functions using the system `python` binary
* `python2.7` for Python Lambda functions using a downloaded Python v2.7.12 binary
* `python3` for Python Lambda functions using the system `python3` binary (or fallback to `python`)
Expand Down
2 changes: 2 additions & 0 deletions src/runtimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as nodejs6 from './runtimes/nodejs6.10';
import * as nodejs8 from './runtimes/nodejs8.10';
import * as nodejs10 from './runtimes/nodejs10.x';
import * as nodejs12 from './runtimes/nodejs12.x';
import * as nodejs14 from './runtimes/nodejs14.x';
import * as python27 from './runtimes/python2.7';
import * as python3 from './runtimes/python3';
import * as python36 from './runtimes/python3.6';
Expand Down Expand Up @@ -50,6 +51,7 @@ createRuntime(runtimes, 'nodejs6.10', nodejs6);
createRuntime(runtimes, 'nodejs8.10', nodejs8);
createRuntime(runtimes, 'nodejs10.x', nodejs10);
createRuntime(runtimes, 'nodejs12.x', nodejs12);
createRuntime(runtimes, 'nodejs14.x', nodejs14);
createRuntime(runtimes, 'python');
createRuntime(runtimes, 'python2.7', python27);
createRuntime(runtimes, 'python3', python3);
Expand Down
9 changes: 9 additions & 0 deletions src/runtimes/nodejs14.x/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -eu

# Ensure the downloaded Node.js version is used
export PATH="$LAMBDA_RUNTIME_DIR/bin:$PATH"

# Execute the "nodejs" runtime bootstrap
export LAMBDA_RUNTIME_DIR="$(dirname "$0")/../nodejs"
exec "$LAMBDA_RUNTIME_DIR/bootstrap" "$@"
6 changes: 6 additions & 0 deletions src/runtimes/nodejs14.x/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { join } from 'path';
import { spawn } from 'child_process';

const nodeBin = join(__dirname, 'bin', 'node');
const bootstrap = join(__dirname, '..', 'nodejs', 'bootstrap.js');
spawn(nodeBin, [bootstrap], { stdio: 'inherit' });
10 changes: 10 additions & 0 deletions src/runtimes/nodejs14.x/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Runtime } from '../../types';
import { installNode } from '../../install-node';
import { runtimes, initializeRuntime } from '../../runtimes';

export async function init({ cacheDir }: Runtime): Promise<void> {
await Promise.all([
initializeRuntime(runtimes.nodejs),
installNode(cacheDir, '12.22.7')
]);
}
16 changes: 16 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,22 @@ export const test_nodejs12_version = testInvoke(
}
);

// `nodejs14.x` runtime
export const test_nodejs14_version = testInvoke(
() =>
createFunction({
Code: {
Directory: __dirname + '/functions/nodejs-version'
},
Handler: 'handler.handler',
Runtime: 'nodejs14.x'
}),
async fn => {
const versions = await fn({ hello: 'world' });
assert.equal(versions.node, '14.18.1');
}
);

// `go1.x` runtime
export const test_go1x_echo = testInvoke(
() =>
Expand Down

0 comments on commit d95c39f

Please sign in to comment.