aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/ci_lint.ts
blob: 3889bf3c81b8857a4a79f51b49e24cf13f3d791a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only

import * as path from 'path';
import { execSync } from 'child_process';
import { program } from 'commander';

function main() {
  program.option('-d, --dir <string>', 'Path to target extension root');
  program.option('-e, --exclude_licenses <string>', 'Exclude packages');
  program.parse(process.argv);
  const options = program.opts();
  const targetExtensionRoot = options.dir as string;
  const extensionRoot = path.resolve(__dirname, '../');
  const excludeLicense = options.exclude_licenses as string;
  execSync(`npm run checkStyle -- --dir="${targetExtensionRoot}"`, {
    cwd: extensionRoot,
    stdio: 'inherit'
  });
  execSync(`eslint . --cache`, {
    cwd: targetExtensionRoot,
    stdio: 'inherit'
  });
  execSync(
    `npm run checkLicenses -- --dir="${targetExtensionRoot}" --exclude="${excludeLicense}"`,
    {
      cwd: extensionRoot,
      stdio: 'inherit'
    }
  );
  execSync(`npm run checkPackage -- --dir="${targetExtensionRoot}"`, {
    cwd: extensionRoot,
    stdio: 'inherit'
  });
}

main();