From 68915241c1017fa943c9fbe833334cb0bd8d268c Mon Sep 17 00:00:00 2001 From: thecodrr Date: Sat, 6 Jul 2019 11:20:19 +0500 Subject: [PATCH 1/2] fix: packager crashing on run-android on Windows --- .../src/commands/runAndroid/index.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/platform-android/src/commands/runAndroid/index.js b/packages/platform-android/src/commands/runAndroid/index.js index a687ff69b..5d661afd1 100644 --- a/packages/platform-android/src/commands/runAndroid/index.js +++ b/packages/platform-android/src/commands/runAndroid/index.js @@ -250,6 +250,23 @@ function startServerInNewWindow(port, terminal, reactNativePath) { ? `set RCT_METRO_PORT=${port}` : `export RCT_METRO_PORT=${port}`; + /** + * Quick & temporary fix for packager crashing on Windows due to using removed --projectRoot flag + * in script. So we just replace the contents of the script with the fixed version. + */ + const launchPackagerScriptContent = `:: Copyright (c) Facebook, Inc. and its affiliates. + :: + :: This source code is licensed under the MIT license found in the + :: LICENSE file in the root directory of this source tree. + + @echo off + title Metro Bundler + call .packager.bat + cd ../../../ + node "%~dp0..\\cli.js" start + pause + exit`; + /** * Set up the `.packager.(env|bat)` file to ensure the packager starts on the right port. */ @@ -296,6 +313,11 @@ function startServerInNewWindow(port, terminal, reactNativePath) { if (/^win/.test(process.platform)) { procConfig.detached = true; procConfig.stdio = 'ignore'; + //Temporary fix for #484. See comment on line 254 + fs.writeFileSync(launchPackagerScript, launchPackagerScriptContent, { + encoding: 'utf8', + flag: 'w', + }); return spawn('cmd.exe', ['/C', launchPackagerScript], procConfig); } logger.error( From 03d439cd656ce8f2dedaa7f0cfa00403e89fb02c Mon Sep 17 00:00:00 2001 From: thecodrr Date: Sat, 6 Jul 2019 11:26:26 +0500 Subject: [PATCH 2/2] chore: improve temp fix comment --- packages/platform-android/src/commands/runAndroid/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/platform-android/src/commands/runAndroid/index.js b/packages/platform-android/src/commands/runAndroid/index.js index 5d661afd1..887fda6a1 100644 --- a/packages/platform-android/src/commands/runAndroid/index.js +++ b/packages/platform-android/src/commands/runAndroid/index.js @@ -252,7 +252,8 @@ function startServerInNewWindow(port, terminal, reactNativePath) { /** * Quick & temporary fix for packager crashing on Windows due to using removed --projectRoot flag - * in script. So we just replace the contents of the script with the fixed version. + * in script. So we just replace the contents of the script with the fixed version. This should be + * removed when PR #25517 on RN Repo gets approved and a new RN version is released. */ const launchPackagerScriptContent = `:: Copyright (c) Facebook, Inc. and its affiliates. ::