Skip to content

Commit

Permalink
Use realpath instead of readlink
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]

Generated with:

```
python3 codemod.py -d xplat/js --extensions=sh 'THIS_DIR=\$\(cd -P "\$\(dirname "\$\(readlink "\${BASH_SOURCE\[0\]}"' 'THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}"'```

Reviewed By: motiz88

Differential Revision: D34379955

fbshipit-source-id: c60521cd6508b203f48ca8c890c450319991c2d4
  • Loading branch information
IanChilds authored and facebook-github-bot committed Feb 22, 2022
1 parent 6b5c3db commit bb8ddd6
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/react-native-codegen/scripts/oss/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# This script assumes yarn is already installed.

THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)

set -e
set -u
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -e
set -u

THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)

# shellcheck source=xplat/js/env-utils/setup_env_vars.sh
source "$THIS_DIR/../../../../../../env-utils/setup_env_vars.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -e
set -u

THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)

# shellcheck source=xplat/js/env-utils/setup_env_vars.sh
source "$THIS_DIR/../../../../../../env-utils/setup_env_vars.sh"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-codegen/src/cli/parser/parser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -e
set -u

THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)

# shellcheck source=xplat/js/env-utils/setup_env_vars.sh
source "$THIS_DIR/../../../../../../env-utils/setup_env_vars.sh"
Expand Down
2 changes: 1 addition & 1 deletion runXcodeTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# This script should be run from the react-native root

THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
source "scripts/.tests.env"

if [ -n "$1" ]
Expand Down
2 changes: 1 addition & 1 deletion scripts/objc-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ xcprettyFormat() {
# Circle CI expects JUnit reports to be available here
REPORTS_DIR="$HOME/react-native/reports/junit"
else
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)

# Write reports to the react-native root dir
REPORTS_DIR="$THIS_DIR/../build/reports"
Expand Down
2 changes: 1 addition & 1 deletion scripts/packager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# 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)
THIS_DIR=$(cd -P "$(dirname "$(realpath "${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/../../.."
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-android-emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# virtual device configuration.
# This is useful for running integration tests on a local machine.

THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)

STATE=`adb get-state`

Expand Down
2 changes: 1 addition & 1 deletion scripts/update_podfile_lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Usage:
# source scripts/update_podfile_lock && update_pods

THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
RNTESTER_DIR="$THIS_DIR/../packages/rn-tester"

# Keep this separate for FB internal access.
Expand Down

2 comments on commit bb8ddd6

@mattijsf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that this realpath is not installed by default on macOS (at least not on 12.2). See also: https://rotadev.com/how-can-i-retrieve-the-absolute-filename-in-a-shell-script-on-mac-os-x-server-fault/

@dminkovsky
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see this confirmed here, thanks @mattijsf. I opened this PR #34145

Please sign in to comment.