Skip to content

Commit 3263277

Browse files
authored
Add MacOS support for typescript model build script (#1457)
* add mac os support for build Signed-off-by: Jordan Dubrick <[email protected]> * update readlink typo Signed-off-by: Jordan Dubrick <[email protected]> --------- Signed-off-by: Jordan Dubrick <[email protected]>
1 parent ee044f7 commit 3263277

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

build/typescript-model/generate.sh

+20-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717

1818
set -e
1919

20-
SCRIPT_DIR=`dirname $( readlink -m $( type -p ${0} ))`
20+
SHORT_NAME="$(uname -s)"
21+
if [ "$(uname)" == "Darwin" ]; then
22+
SCRIPT_DIR=`dirname $( realpath $( type -p ${0} ))`
23+
else
24+
SCRIPT_DIR=`dirname $( readlink -m $( type -p ${0} ))`
25+
fi
2126
WORK_DIR=${SCRIPT_DIR}/workdir
2227
echo "[INFO] Using the following folder to store all build files ${SCRIPT_DIR}/workdir"
2328
mkdir -p $WORK_DIR
@@ -48,11 +53,12 @@ EOF
4853
export OPENAPI_GENERATOR_COMMIT="v6.3.0"
4954
bash $WORK_DIR/gen/openapi/typescript.sh $WORK_DIR/typescript-models $WORK_DIR/config.sh
5055

51-
sed -i 's/\"name\": \".*\"/"name": "@devfile\/api"/g' $WORK_DIR/typescript-models/package.json
52-
sed -i 's/\"description\": \".*\"/"description": "Typescript types for devfile api"/g' $WORK_DIR/typescript-models/package.json
53-
sed -i 's/\"repository\": \".*\"/"repository": "devfile\/api"/g' $WORK_DIR/typescript-models/package.json
54-
sed -i 's/\"license\": \".*\"/"license": "Apache-2.0"/g' $WORK_DIR/typescript-models/package.json
55-
sed -i 's/\"@types\/bluebird\": \".*\"/"@types\/bluebird": "3.5.21"/g' $WORK_DIR/typescript-models/package.json
56+
apply_sed 's/\"name\": \".*\"/"name": "@devfile\/api"/g' $WORK_DIR/typescript-models/package.json
57+
apply_sed 's/\"description\": \".*\"/"description": "Typescript types for devfile api"/g' $WORK_DIR/typescript-models/package.json
58+
apply_sed 's/\"repository\": \".*\"/"repository": "devfile\/api"/g' $WORK_DIR/typescript-models/package.json
59+
apply_sed 's/\"license\": \".*\"/"license": "Apache-2.0"/g' $WORK_DIR/typescript-models/package.json
60+
apply_sed 's/\"@types\/bluebird\": \".*\"/"@types\/bluebird": "3.5.21"/g' $WORK_DIR/typescript-models/package.json
61+
5662
echo "" > $WORK_DIR/typescript-models/.npmignore
5763
echo "[INFO] Generated typescript model which now is available in $WORK_DIR/typescript-models"
5864
}
@@ -80,6 +86,14 @@ build_typescript_model() {
8086
echo "[INFO] Done."
8187
}
8288

89+
apply_sed(){
90+
if [ "$(uname)" == "Darwin" ]; then
91+
sed -i '' "$@"
92+
else
93+
sed -i "$@"
94+
fi
95+
}
96+
8397
generate_swagger_json
8498
k8s_client_gen
8599
generate_typescript_metadata

0 commit comments

Comments
 (0)