1/* 2 * Copyright (c) 2021-2022 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 16function checkEntryLocalText(url, prId) { 17 const path = require('path'); 18 let result = []; 19 try { 20 let execSync = require("child_process").execSync; 21 execSync("cd ../../api_diff && npm install && cd ../api_check_plugin && npm install"); 22 const { excelApiCheckResult, apiCheckArr, removeDir } = 23 require(path.resolve(__dirname, '../src/utils')); 24 const { scanEntry } = require('../src/api_check_plugin'); 25 result = scanEntry(url, prId, false); 26 excelApiCheckResult(apiCheckArr); 27 removeDir(path.resolve(__dirname, "../../api_diff/node_modules")); 28 removeDir(path.resolve(__dirname, "../node_modules")); 29 } catch (error) { 30 result.push(`API_CHECK_ERROR :${error}`); 31 console.error(`API_CHECK_ERROR :${error}`); 32 } finally { 33 const { apiCheckInfoArr, removeDuplicateObj } = require('../src/utils'); 34 const apiCheckResultArr = removeDuplicateObj(apiCheckInfoArr); 35 apiCheckResultArr.forEach(errorInfo => { 36 result.unshift(errorInfo); 37 }); 38 const { writeResultFile } = require('../src/utils'); 39 writeResultFile(result, path.resolve(__dirname, './Result.txt'), {}); 40 } 41} 42 43// 修改为实际的prId 44const prId = 'xxx'; 45checkEntryLocalText('./mdFiles.txt', prId); 46