Skip to content

Commit f8d59fe

Browse files
committed
Adds support for Darwin os client generation
1 parent 58ba9fd commit f8d59fe

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

scripts/generate_api_client.sh

+15-14
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,27 @@ echo ""
44
echo "Please make sure that you have already updated the src/xpanse-api/api.json."
55
echo ""
66
echo -n "Press any key to continue..."
7-
read answer
7+
read -r answer
88

9-
# Get the directory of the currently running script
10-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
9+
SCRIPT_DIR="$(cd "$(dirname "$0")" &&
10+
API_DIR="${SCRIPT_DIR}/../src/xpanse-api/"
1111
12-
# Get the root directory of xpanse-api
13-
API_DIR=${SCRIPT_DIR}/../src/xpanse-api/
14-
15-
# Generate API files
1612
npx @hey-api/openapi-ts
1713
18-
$(
19-
cd ${API_DIR}
14+
(
15+
cd "${API_DIR}" || exit 1
16+
17+
FILE_NEED_ADD_LICENSE=$(grep -L "SPDX-License-Identifier" ./ --exclude='*.json' -R)
2018
21-
FILE_NEED_ADD_LICENSE=$(grep -L "SPDX-License-Identifier" ./ --exclude *.json -R)
19+
for FILE in $FILE_NEED_ADD_LICENSE; do
20+
echo "Updating license header in: $FILE"
2221
23-
for FILE in $FILE_NEED_ADD_LICENSE
24-
do
25-
echo $FILE
26-
sed -i '1s#^#/*\n * SPDX-License-Identifier: Apache-2.0\n * SPDX-FileCopyrightText: Huawei Inc.\n */\n\n#' $FILE
22+
if [[ "$OSTYPE" == "darwin"* ]]; then
23+
sed -i '' '1s#^#/*\n * SPDX-License-Identifier: Apache-2.0\n * SPDX-FileCopyrightText: Huawei Inc.\n */\n\n#' "$FILE"
24+
else
25+
# Linux
26+
sed -i '1s#^#/*\n * SPDX-License-Identifier: Apache-2.0\n * SPDX-FileCopyrightText: Huawei Inc.\n */\n\n#' "$FILE"
27+
fi
2728
done
2829
)
2930

0 commit comments

Comments
 (0)