Improve documentation and add Pijul installation configuration

[?]
Dec 22, 2020, 7:55 PM
WHFIIX4YN26GWZKAKBLUBK5262SREOCSU3LHI5KJMHBPSAUYLUZAC

Dependencies

  • [2] WW67NYZV Configure eslint for JS standard formatting
  • [3] NCBEWRYE Initialize Repository
  • [4] 3N3RS66T Create pijul output channel and configure activation events

Change contents

  • edit in src/extension.ts at line 2
    [3.106975]
    [2.19657]
    import * as cp from "child_process";
  • edit in src/extension.ts at line 4
    [2.19691]
    [3.107088]
    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()));
    }
  • replacement in src/extension.ts at line 60
    [2.19696][2.19696:19833]()
    * Nested activation function. Other source control extensions use this patten, though I can't
    * say I'm clear on the advantages of it.
    [2.19696]
    [2.19833]
    * Nested activation function which is only run after the configuration has been checked and the extension
    * is confirmed to be enabled.
  • edit in src/extension.ts at line 63
    [2.19873]
    [2.19873]
    * @param config The extension configuration
  • replacement in src/extension.ts at line 66
    [2.19983][2.19983:20079]()
    async function _activate (context: vscode.ExtensionContext, disposables: vscode.Disposable[]) {
    [2.19983]
    [2.20079]
    async function _activate (_context: vscode.ExtensionContext, config: vscode.WorkspaceConfiguration, disposables: vscode.Disposable[]) {
  • edit in src/extension.ts at line 73
    [2.20453][3.107283:107284](),[3.462][3.107283:107284](),[3.107283][3.107283:107284](),[3.107284][2.20454:20565]()
    const config = vscode.workspace.getConfiguration("pijul");
    const enabled = config.get<boolean>("enabled");
  • replacement in src/extension.ts at line 74
    [3.107540][2.20566:20690]()
    if (enabled) {
    console.log("test");
    } else {
    // Wait for a configuration change which enables the extension
    }
    [3.107540]
    [2.20690]
    await checkPijulInstallation(config, outputChannel);
  • replacement in src/extension.ts at line 103
    [2.21484][2.21484:21558]()
    await _activate(context, disposables).catch(err => console.error(err));
    [2.21484]
    [2.21558]
    const config = vscode.workspace.getConfiguration("pijul");
    const enabled = config.get<boolean>("enabled");
    if (enabled) {
    await _activate(context, config, disposables).catch(err => console.error(err));
    } else {
    // TODO: Wait for a configuration change which enables the extension
    }