blob: 553934a59f06436a3bd2c8ad30748a3b9ae123e1 (
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
38
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only
import * as vscode from 'vscode';
import { spawnSync } from 'child_process';
import { QtAdditionalPath, inVCPKGRoot } from 'qt-lib';
import { EXTENSION_ID } from '@/constants';
import untildify from 'untildify';
export function getConfiguration(scope?: vscode.ConfigurationScope) {
return vscode.workspace.getConfiguration(EXTENSION_ID, scope);
}
export function convertAdditionalQtPaths(
value: (string | object)[]
): QtAdditionalPath[] {
return value.map((element) => {
if (typeof element === 'string') {
return { path: untildify(element), isVCPKG: inVCPKGRoot(element) };
}
const ret = element as QtAdditionalPath;
ret.isVCPKG = inVCPKGRoot(ret.path);
ret.path = untildify(ret.path);
return ret;
});
}
export function getQueryOutput(exePath: string) {
const ret = spawnSync(exePath, ['-query'], {
encoding: 'utf8',
timeout: 1000
});
if (ret.error ?? ret.status !== 0) {
return undefined;
}
return ret;
}
|