1/* 2 * Copyright (c) 2021 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 16"use strict"; 17var path = require("path"); 18var fs = require("fs"); 19let exec = require('child_process').exec; 20 21const arkDir = path.resolve(__dirname, 'bin', "ark"); 22if (!fs.existsSync(arkDir)) { 23 return; 24} 25 26var isWin = !1; 27var isMac = !1; 28 29if (fs.existsSync(path.join(arkDir, "build-win"))) { 30 isWin = !0; 31} else if (fs.existsSync(path.join(arkDir, "build-mac"))) { 32 isMac = !0; 33} else if (!fs.existsSync(path.join(arkDir, "build"))) { 34 throw Error("Error: find build fail").message; 35} 36 37let cwd; 38if (isWin) { 39 cwd = path.join(arkDir, "build-win"); 40} else if (isMac) { 41 cwd = path.join(arkDir, "build-mac"); 42} else { 43 cwd = path.join(arkDir, "build"); 44} 45 46cwd = path.join(cwd, "legacy_api8"); 47 48exec("npm install", { cwd: cwd }, function (err, stdout, stderr) { 49 console.log("[31m", stdout, "[39m"); 50 if (err != null) { 51 throw Error(`npm install filed: ${err}`).message; 52 } 53}); 54