element-desktop/hak/keytar/check.ts

32 lines
992 B
TypeScript
Raw Normal View History

2020-05-28 21:07:39 +02:00
/*
2024-09-06 18:56:18 +02:00
Copyright 2024 New Vector Ltd.
2020-05-28 21:07:39 +02:00
Copyright 2020 The Matrix.org Foundation C.I.C.
2024-09-06 18:56:18 +02:00
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
2020-05-28 21:07:39 +02:00
*/
2022-12-15 12:00:58 +01:00
import childProcess from "child_process";
2020-05-28 21:07:39 +02:00
2022-12-15 12:00:58 +01:00
import HakEnv from "../../scripts/hak/hakEnv";
import { DependencyInfo } from "../../scripts/hak/dep";
2022-12-15 12:00:58 +01:00
export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
const tools = [["python", "--version"]]; // node-gyp uses python for reasons beyond comprehension
2020-05-28 21:07:39 +02:00
for (const tool of tools) {
await new Promise<void>((resolve, reject) => {
2020-05-28 21:07:39 +02:00
const proc = childProcess.spawn(tool[0], tool.slice(1), {
2022-12-15 12:00:58 +01:00
stdio: ["ignore"],
2020-05-28 21:07:39 +02:00
});
2022-12-15 12:00:58 +01:00
proc.on("exit", (code) => {
2020-05-28 21:07:39 +02:00
if (code !== 0) {
reject("Can't find " + tool);
} else {
resolve();
}
});
});
}
}