From 423fee620ab5e6e5fa8a31a8efcb13bce68c3314 Mon Sep 17 00:00:00 2001 From: Matthieu Lemoine <8517072+MatthieuLemoine@users.noreply.github.com> Date: Wed, 20 Mar 2019 18:23:40 +0100 Subject: [PATCH] fix: Start Metro packager from $PROJECT_DIR --- scripts/packager.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/packager.sh b/scripts/packager.sh index 6cab21b669eeb9..e5bb1e903f0282 100755 --- a/scripts/packager.sh +++ b/scripts/packager.sh @@ -4,9 +4,20 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. +# scripts directory THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) +REACT_NATIVE_ROOT="$THIS_DIR/.." +# Application root directory - General use case: react-native is a dependency +PROJECT_ROOT="$THIS_DIR/../../.." # shellcheck source=/dev/null source "${THIS_DIR}/.packager.env" -cd "$THIS_DIR/.." || exit -node "./cli.js" start "$@" + +# When running react-native tests, react-native doesn't live in node_modules but in the PROJECT_ROOT +if [ ! -d "$PROJECT_ROOT/node_modules/react-native" ]; +then + PROJECT_ROOT="$THIS_DIR/.." +fi +# Start packager from PROJECT_ROOT +cd "$PROJECT_ROOT" || exit +node "$REACT_NATIVE_ROOT/cli.js" start "$@"