Base64Png VS Code package.json activate part2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as vscode from "vscode"; | |
import * as path from "path"; | |
import * as fs from "fs"; | |
let backendProxy: VsCodeBackendProxy; | |
export function activate(context: vscode.ExtensionContext) { | |
// ... | |
context.subscriptions.push( | |
vscode.commands.registerCommand("extension.kogito.createBase64Png", (file: { fsPath: string }) => { | |
const buffer = fs.readFileSync(file.fsPath); | |
const parsedPath = path.parse(file.fsPath); | |
const base64FileName = `${parsedPath.name}${parsedPath.ext}.base64png`; | |
const base64AbsoluteFilePath = path.join(parsedPath.dir, base64FileName); | |
fs.writeFileSync(base64AbsoluteFilePath, buffer.toString("base64")); | |
vscode.window.showInformationMessage("Generated the Base64 file with success!", "Open").then((selected) => { | |
if (!selected) { | |
return; | |
} | |
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(base64AbsoluteFilePath)); | |
}); | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment