const vscode = require("vscode"); const path = require("path"); const fs = require("fs"); const getCommits = require("./git"); // this method is called when your extension is activated // your extension is activated the very first time the command is executed /** * @param {vscode.ExtensionContext} context */ function activate(context) { // The command has been defined in the package.json file // Now provide the implementation of the command with registerCommand // The commandId parameter must match the command field in package.json let disposable = vscode.commands.registerCommand( "extension.git-file-history", function() { // The code you place here will be executed every time your command is executed try { const currentPath = getCurrentPath(); if (!currentPath) { vscode.window.showInformationMessage("No active file"); return; } const panel = vscode.window.createWebviewPanel( "gfh", `${path.basename(currentPath)} (Git History)`, vscode.ViewColumn.One, { enableScripts: true, retainContextWhenHidden: true, localResourceRoots: [ vscode.Uri.file(path.join(context.extensionPath, "site")) ] } ); const indexPath = path.join( context.extensionPath, "site", "index.html" ); const index = fs.readFileSync(indexPath, "utf-8"); const newIndex = index .replace( "
", `` ) .replace( "", `