mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
55 lines
1.6 KiB
Bash
Executable File
55 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Exit the script as soon as an error occurs.
|
|
set -e
|
|
|
|
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
|
SED_COMMAND=sed
|
|
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
|
if ! command -v gsed &> /dev/null; then
|
|
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
|
exit 1
|
|
fi
|
|
SED_COMMAND=gsed
|
|
fi
|
|
|
|
# This script renames the `ripple` namespace to `xrpl` in this project.
|
|
# Specifically, it renames all occurrences of `namespace ripple` and `ripple::`
|
|
# to `namespace xrpl` and `xrpl::`, respectively, by scanning all header and
|
|
# source files in the specified directory and its subdirectories, as well as any
|
|
# occurrences in the documentation.
|
|
# Usage: .github/scripts/rename/namespace.sh <repository directory>
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
echo "Usage: $0 <repository directory>"
|
|
exit 1
|
|
fi
|
|
|
|
DIRECTORY=$1
|
|
echo "Processing directory: ${DIRECTORY}"
|
|
if [ ! -d "${DIRECTORY}" ]; then
|
|
echo "Error: Directory '${DIRECTORY}' does not exist."
|
|
exit 1
|
|
fi
|
|
pushd ${DIRECTORY}
|
|
|
|
DIRECTORIES=("include" "src" "tests")
|
|
for DIRECTORY in "${DIRECTORIES[@]}"; do
|
|
echo "Processing directory: ${DIRECTORY}"
|
|
|
|
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.cpp" \) | while read -r FILE; do
|
|
echo "Processing file: ${FILE}"
|
|
${SED_COMMAND} -i 's/namespace ripple/namespace xrpl/g' "${FILE}"
|
|
${SED_COMMAND} -i 's/ripple::/xrpl::/g' "${FILE}"
|
|
done
|
|
done
|
|
|
|
DIRECTORY=$1
|
|
find "${DIRECTORY}" -type f -name "*.md" | while read -r FILE; do
|
|
echo "Processing file: ${FILE}"
|
|
${SED_COMMAND} -i 's/ripple::/xrpl::/g' "${FILE}"
|
|
done
|
|
|
|
popd
|
|
echo "Renaming complete."
|