Last active
October 13, 2020 21:30
-
-
Save ljmotta/df0d27d84c6e4371637c2bc572d8e8e3 to your computer and use it in GitHub Desktop.
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