1/* 2 * Copyright (c) 2023 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 16const fs = require('fs'); 17const { spawnSync } = require('child_process'); 18const path = require('path'); 19const os = require('os'); 20function compileMock(apiInputPath) { 21 const mockJsPath = path.join(__dirname, '..', './runtime/main/extend/systemplugin'); 22 let nodeDir = ''; 23 nodeDir = './current/bin/node'; 24 25 26 const bat = spawnSync(` 27 ${path.join(__dirname, '..', nodeDir)} ${path.join(__dirname, '..', './node_modules/typescript/bin/tsc')} && 28 ${path.join(__dirname, '..', nodeDir)} ${path.join(__dirname, 'dist')}/main.js ${apiInputPath} && 29 ${path.join(__dirname, '..', nodeDir)} ${path.join(__dirname, '..', './node_modules/eslint/bin/eslint.js')} 30 -c .eslintrc --fix ${mockJsPath}/**/*.js`, { 31 cwd: __dirname, 32 shell: true 33 }); 34} 35const PARAM_INDEX = 2; 36const apiInputPath = process.argv[PARAM_INDEX]; 37compileMock(apiInputPath); 38