• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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() {
21  const mockJsPath = path.join(__dirname, '..', './runtime/main/extend/systemplugin');
22  let nodeDir = '';
23  if (os.platform() === 'linux') {
24    nodeDir = './node-v12.18.4-linux-x64/bin/node';
25  } else {
26    nodeDir = './node-v12.18.4-darwin-x64/bin/node';
27  }
28
29  const bat = spawnSync(`
30  ${path.join(__dirname, '..', nodeDir)} ${path.join(__dirname, '..','./node_modules/typescript/bin/tsc')} &&
31  ${path.join(__dirname, '..', nodeDir)} ${path.join(__dirname, 'dist')}/main.js &&
32  ${path.join(__dirname, '..', nodeDir)} ${path.join(__dirname, '..', './node_modules/eslint/bin/eslint.js')}
33  -c .eslintrc --fix ${mockJsPath}/**/*.js`, {
34    cwd: __dirname,
35    shell: true
36  });
37}
38
39compileMock();
40