idlize
/
download-sdk.mjs
38 строк · 1.2 Кб
1/*
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
16import * as fs from "node:fs"17import { execSync } from "node:child_process"18
19const dir = "./interface_sdk-js"20
21if (fs.existsSync(dir)) {22//execSync(`cd ${dir} && git pull`)23} else {24console.log("Downloading sdk")25execSync("git clone --depth=1 https://gitee.com/openharmony/interface_sdk-js.git")26}
27
28let sdk = "./sdk"29let components = "./interface_sdk-js/api/\@internal/component/ets"30if (!fs.existsSync(sdk)) {31fs.mkdirSync(sdk)32try {33fs.symlinkSync("." + components, sdk + "/component")34} catch (e) {35console.log("Symlink failed, try to copy")36fs.cpSync(components, sdk + "/component", { recursive: true })37}38}
39