• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 { existsSync, copyFileSync } from 'node:fs';
17import * as path from 'node:path';
18import { exit } from 'node:process';
19
20const SCRIPTS = [
21    'print_cmd_line_args.bat',
22    'print_cmd_line_args.js',
23    'print_cmd_line_args.sh',
24]
25
26function reportErrorAndExit(msg) {
27    console.log(msg);
28    exit(1);
29}
30
31function copyTestRunnerScriptsToBuild() {
32    const srcDir = path.join('scripts', 'testRunner');
33    const distDir = path.join('build', 'testRunner');
34    if (!existsSync(srcDir)) {
35        reportErrorAndExit('Failed to locate ' + srcDir + ' directory');
36    }
37    if (!existsSync(distDir)) {
38        reportErrorAndExit('Failed to locate ' + distDir + ' directory');
39    }
40    for (const script of SCRIPTS) {
41        const srcPath = path.resolve(srcDir, script);
42        const distPath = path.resolve(distDir, script);
43        copyFileSync(srcPath, distPath);
44    }
45}
46
47copyTestRunnerScriptsToBuild();