From 699a0bef3b2e6be3544db2486af5fdf18b224372 Mon Sep 17 00:00:00 2001 From: Rob Hogan Date: Tue, 6 Jun 2017 11:19:00 -0700 Subject: [PATCH] Fail gracefully for node<4 in react-native-cli (const->var) Summary: `const` declarations were recently introduced into https://github.com/facebook/react-native/blob/master/react-native-cli/index.js, which runs before any transpilation so needs to be old-school. Replace them with `var`. Fixes https://github.com/facebook/react-native/issues/11603 Closes https://github.com/facebook/react-native/pull/11615 Differential Revision: D5148448 Pulled By: shergin fbshipit-source-id: ea23cdd26c0c1d0ac7f108aa9bf185abecfe399c --- react-native-cli/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/react-native-cli/index.js b/react-native-cli/index.js index e35831547c5..4de761a7ff4 100755 --- a/react-native-cli/index.js +++ b/react-native-cli/index.js @@ -26,6 +26,9 @@ // The only reason to modify this file is to add more warnings and // troubleshooting information for the `react-native init` command. // +// To allow for graceful failure on older node versions, this file should +// retain ES5 compatibility. +// // Do not make breaking changes! We absolutely don't want to have to // tell people to update their global version of react-native-cli. // @@ -266,9 +269,9 @@ function getInstallPackage(rnPackage) { } function run(root, projectName, options) { - const rnPackage = options.version; // e.g. '0.38' or '/path/to/archive.tgz' - const forceNpmClient = options.npm; - const yarnVersion = (!forceNpmClient) && getYarnVersionIfAvailable(); + var rnPackage = options.version; // e.g. '0.38' or '/path/to/archive.tgz' + var forceNpmClient = options.npm; + var yarnVersion = (!forceNpmClient) && getYarnVersionIfAvailable(); var installCommand; if (options.installCommand) { // In CI environments it can be useful to provide a custom command,