1#!/bin/bash
2# Copyright (c) 2024 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Install typescript from third_party/typescript
16# Must run this script in arkguard root directory.
17
18set -e
19
20if [ ! -d "../arkguard" ]; then
21    echo "Error: must run this script in arkguard root directory"
22    exit 1
23fi
24
25TYPESCRIPT_ROOT_DIR="../../../third_party/typescript"
26old_work_dir=$(pwd)
27
28echo "-----------------------------start building typescript-----------------------------"
29cd $TYPESCRIPT_ROOT_DIR
30package_name=$(npm pack | grep "ohos-typescript")
31echo $package_name
32tar -xvf $package_name
33current_dir=$(pwd)
34package_path="$current_dir/package"
35echo "-----------------------------end building typescript-----------------------------"
36
37cd $old_work_dir
38target_dir=./node_modules/typescript
39
40echo "move $package_path to override $target_dir"
41
42if [ -d "$target_dir" ]; then
43    rm -r "$target_dir"
44else
45    echo "$target_dir does not exist. No need to remove."
46fi
47
48mv $package_path $target_dir
49echo "------------------------------------finished-------------------------------------"
50