Improve documentation and add Pijul installation configuration
[?]
Dec 22, 2020, 7:55 PM
WHFIIX4YN26GWZKAKBLUBK5262SREOCSU3LHI5KJMHBPSAUYLUZACDependencies
- [2]
WW67NYZVConfigure eslint for JS standard formatting - [3]
NCBEWRYEInitialize Repository - [4]
3N3RS66TCreate pijul output channel and configure activation events
Change contents
- edit in src/extension.ts at line 2
import * as cp from "child_process"; - edit in src/extension.ts at line 4
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 activationif (!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 locationconst 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 safetyreturn;}} else {config.update("ignoreMissingInstallation", true);return;}} else {// TODO: Wait for change to the configurationreturn;}}const child = cp.spawn(path, ["--version"]);child.stdout.on("data", (b: Buffer) => outputChannel.append(b.toString()));} - replacement in src/extension.ts at line 60
* Nested activation function. Other source control extensions use this patten, though I can't* say I'm clear on the advantages of it.* 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
* @param config The extension configuration - replacement in src/extension.ts at line 66
async function _activate (context: vscode.ExtensionContext, disposables: vscode.Disposable[]) {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
if (enabled) {console.log("test");} else {// Wait for a configuration change which enables the extension}await checkPijulInstallation(config, outputChannel); - replacement in src/extension.ts at line 103
await _activate(context, disposables).catch(err => console.error(err));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}