Skip to content

Commit 33e822e

Browse files
committed
fix(start): update messaging for different Node.js version (#22)
fix #22
1 parent 9f56095 commit 33e822e

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/commands/start.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import debug from 'debug';
2+
import { Argv } from 'yargs';
3+
import { printRouteInfo, printVersionWarning } from '../printers/start';
4+
import { getConfigFromCli, StartCliFlags } from '../runtime/cli/config';
25
import { createServer } from '../runtime/server';
36
import { startInspector } from '../runtime/utils/inspector';
4-
import { getConfigFromCli, StartCliFlags } from '../runtime/cli/config';
5-
import { printRouteInfo, printVersionWarning } from '../printers/start';
6-
import { Argv } from 'yargs';
77
import { CliInfo } from './types';
88

99
const log = debug('twilio-run:start');
1010

11+
const SERVERLESS_NODE_JS_VERSION = '8.10';
12+
1113
export async function handler(argv: StartCliFlags): Promise<void> {
1214
const nodeVersion = process.versions.node;
13-
if (!nodeVersion.startsWith('8.10')) {
14-
printVersionWarning(nodeVersion);
15+
if (!nodeVersion.startsWith(SERVERLESS_NODE_JS_VERSION)) {
16+
printVersionWarning(nodeVersion, SERVERLESS_NODE_JS_VERSION);
1517
}
1618

1719
const cli = {

src/printers/start.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import boxen from 'boxen';
22
import chalk from 'chalk';
33
import { stripIndent } from 'common-tags';
4-
import wrapAnsi from 'wrap-ansi';
5-
import size from 'window-size';
64
import logSymbols from 'log-symbols';
5+
import size from 'window-size';
6+
import wrapAnsi from 'wrap-ansi';
7+
import { StartCliConfig } from '../runtime/cli/config';
78
import {
8-
getFunctionsAndAssets,
9-
FunctionInfo,
109
AssetInfo,
10+
FunctionInfo,
11+
getFunctionsAndAssets,
1112
} from '../runtime/internal/runtime-paths';
1213
import { shouldPrettyPrint, terminalLink } from './utils';
13-
import { StartCliConfig } from '../runtime/cli/config';
1414

1515
function printAsset(asset: AssetInfo, config: StartCliConfig): string {
1616
const prefix = config.legacyMode ? '/asset' : '';
@@ -138,13 +138,16 @@ export async function printRouteInfo(config: StartCliConfig): Promise<void> {
138138
console.log(output);
139139
}
140140

141-
export function printVersionWarning(nodeVersion: string): void {
141+
export function printVersionWarning(
142+
nodeVersion: string,
143+
expectedVersion: string
144+
): void {
142145
const msg = chalk`
143146
{underline.bold {yellow WARNING!} {bold Different Node.js version}}
144147
145-
You are currently running ${nodeVersion} but the Twilio Runtime is runnning version 8.10.
148+
You are currently running Node.js ${nodeVersion} on this local machine. The production environment for Twilio Serverless is currently on ${expectedVersion}.
146149
147-
You might encounter differences between local development and production.
150+
When you deploy to Twilio Serverless, you may encounter differences between local development and production.
148151
149152
For a more accurate local development experience, please switch your Node.js version.
150153
A tool like nvm (https://github.com/creationix/nvm) can help.

0 commit comments

Comments
 (0)