Skip to content

Commit 77551cd

Browse files
authored
feat(twilio-run): add default runtime for config file (#379)
1 parent 41b3e15 commit 77551cd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: packages/twilio-run/__tests__/templating/__snapshots__/defaultConfig.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ exports[`writeDefaultConfigFile default file should match snapshot 1`] = `
3636
// \\"production\\": false /* Promote build to the production environment (no domain suffix). Overrides environment flag */,
3737
// \\"properties\\": null /* Specify the output properties you want to see. Works best on single types */,
3838
// \\"region\\": null /* Twilio API Region */,
39-
// \\"runtime\\": null /* The version of Node.js to deploy the build to. (node12 or node14) */,
39+
\\"runtime\\": \\"node12\\" /* The version of Node.js to deploy the build to. (node12 or node14) */,
4040
// \\"serviceName\\": null /* Overrides the name of the Serverless project. Default: the name field in your package.json */,
4141
// \\"serviceSid\\": null /* SID of the Twilio Serverless Service to deploy to */,
4242
// \\"sourceEnvironment\\": null /* SID or suffix of an existing environment you want to deploy from. */,

Diff for: packages/twilio-run/src/templating/defaultConfig.ts

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { getDebugFunction } from '../utils/logger';
99

1010
const debug = getDebugFunction('twilio-run:templating:defaultConfig');
1111

12+
const DEFAULT_RUNTIME = 'node12';
13+
1214
function renderDefault(config: Options): string {
1315
if (config.type === 'boolean') {
1416
if (typeof config.default === 'boolean') {
@@ -26,6 +28,13 @@ function renderDefault(config: Options): string {
2628
}
2729

2830
function templateFlagAsConfig([flag, config]: [string, Options]) {
31+
if (flag === 'runtime' && typeof config.default !== 'string') {
32+
// special case for runtime with a hard coded default for a better Node.js transition
33+
return `\t"${camelCase(flag)}": "${DEFAULT_RUNTIME}" \t/* ${
34+
config.describe
35+
} */,`;
36+
}
37+
2938
return `\t// "${camelCase(flag)}": ${renderDefault(config)} \t/* ${
3039
config.describe
3140
} */,`;

0 commit comments

Comments
 (0)