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 "$@"