1#!/bin/bash
2# Copyright (c) Meta Platforms, Inc. and affiliates.
3# Copyright 2018-present 650 Industries. All rights reserved.
4#
5# @generated by expo-module-scripts
6#
7# USAGE:
8# ./with-node.sh command
9
10CURR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
11
12# Start with a default
13NODE_BINARY=$(command -v node)
14export NODE_BINARY
15
16# Override the default with the global environment
17ENV_PATH="$PODS_ROOT/../.xcode.env"
18if [[ -f "$ENV_PATH" ]]; then
19  source "$ENV_PATH"
20fi
21
22# Override the global with the local environment
23LOCAL_ENV_PATH="${ENV_PATH}.local"
24if [[ -f "$LOCAL_ENV_PATH" ]]; then
25  source "$LOCAL_ENV_PATH"
26fi
27
28if [[ -n "$NODE_BINARY" && -x "$NODE_BINARY" ]]; then
29  echo "Node found at: ${NODE_BINARY}"
30else
31  cat >&2 << EOF
32[ERROR] Could not find "node" while running an Xcode build script. You need to specify the path to your Node.js executable by defining an environment variable named NODE_BINARY in your project's .xcode.env or .xcode.env.local file. You can set this up quickly by running:
33
34  echo "export NODE_BINARY=\$(command -v node)" >> .xcode.env
35
36in the ios folder of your project.
37EOF
38  exit 1
39fi
40
41# Execute argument, if present
42if [[ "$#" -gt 0 ]]; then
43  "$NODE_BINARY" "$@"
44fi
45