async function checkPijulInstallation (config: vscode.WorkspaceConfiguration, outputChannel: vscode.OutputChannel) {
let path = config.get<string>("installationPath");
if (!path) {
// We need a path to proceed, ask the user to select one or stop activation
if (!config.get<boolean>("ignoreMissingInstallation")) {
const selectInstallation = "Select a Pijul Executable";
const ignore = "Don't Show this Warning Again";
const choice = await vscode.window.showWarningMessage(
"No Pijul installation has been configured for use with the extension. Select one to enable Pijul integration",
selectInstallation,
ignore
);
if (choice === selectInstallation) {
let fileFilters: { [name: string]: string[] } | undefined;
if (process.platform === "win32") {
fileFilters = {
svn: ["exe", "bat"]
};
}
// Ask the user to select an executable location
const pijulInstallation = await vscode.window.showOpenDialog({
canSelectFiles: true,
canSelectFolders: false,
canSelectMany: false,
filters: fileFilters
});
if (pijulInstallation && pijulInstallation[0]) {
const exePath = pijulInstallation[0].fsPath;
await config.update("installationPath", exePath);
path = exePath;
outputChannel.appendLine("Updated extension configuration to use Pijul installation at " + exePath);
} else {
// Not sure if this case is possible, this is here for safety
return;
}
} else {
config.update("ignoreMissingInstallation", true);
return;
}
} else {
// TODO: Wait for change to the configuration
return;
}
}
const child = cp.spawn(path, ["--version"]);
child.stdout.on("data", (b: Buffer) => outputChannel.append(b.toString()));
}