From 2d20fb9ec361ffaba55b7a5acaa761486debcfdf Mon Sep 17 00:00:00 2001 From: Zentino Date: Fri, 6 Dec 2024 12:49:54 +0800 Subject: [PATCH 1/3] feat: auto apply checksum when starting VSCode Co-authored-by: Iewnfod --- package.json | 12 +++++++++++- src/extension.js | 9 +++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5106554..0bb1f34 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,17 @@ "command": "fixChecksums.restore", "title": "Fix Checksums: Restore" } - ] + ], + "configuration": { + "title": "vscode-fix-checksums", + "properties": { + "checksums.autoFix": { + "type": "boolean", + "description": "Fix checksums automatically when VSCode start up", + "default": false + } + } + } }, "scripts": { "vscode:prepublish": "pnpm build", diff --git a/src/extension.js b/src/extension.js index aceb78f..7ccd01a 100644 --- a/src/extension.js +++ b/src/extension.js @@ -17,6 +17,9 @@ exports.activate = function activate(context) { vscode.commands.registerCommand('fixChecksums.restore', restore) ) cleanupOrigFiles() + + const auto = vscode.workspace.getConfiguration().get("checksums.autoFix") + apply(auto) } const messages = { @@ -27,7 +30,7 @@ const messages = { Make sure you have write access rights to the VSCode files, see README`, } -async function apply() { +async function apply(hidden) { const product = requireUncached(productFile) if (!product.checksums) { vscode.window.showInformationMessage(messages.unchanged) @@ -54,7 +57,9 @@ async function apply() { message = messages.error } } - vscode.window.showInformationMessage(message); + if (hidden !== true) { + vscode.window.showInformationMessage(message); + } } async function restore() { From 3097b3652ed3f8fe3be940be728d166adfec8518 Mon Sep 17 00:00:00 2001 From: Zentino Date: Sat, 7 Dec 2024 00:39:03 +0800 Subject: [PATCH 2/3] fix auto apply --- .vscode/launch.json | 3 ++- src/extension.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 7bc18a4..12d1dc2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,7 +12,8 @@ "runtimeExecutable": "${execPath}", "args": [ "--extensionDevelopmentPath=${workspaceFolder}" - ] + ], + "outFiles": ["${workspaceFolder}/src/**/*.js"] } ] } \ No newline at end of file diff --git a/src/extension.js b/src/extension.js index 7ccd01a..22d03cf 100644 --- a/src/extension.js +++ b/src/extension.js @@ -19,7 +19,8 @@ exports.activate = function activate(context) { cleanupOrigFiles() const auto = vscode.workspace.getConfiguration().get("checksums.autoFix") - apply(auto) + if (auto) + apply(auto) } const messages = { From 86ca5f8437140944e95cac72e4369e47b704d2cb Mon Sep 17 00:00:00 2001 From: Zentino Date: Sat, 7 Dec 2024 01:10:39 +0800 Subject: [PATCH 3/3] Auto start the plugin for auto-apply to function --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0bb1f34..d91916e 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,9 @@ "categories": [ "Other" ], + "activationEvents": [ + "onStartupFinished" + ], "contributes": { "commands": [ { @@ -74,4 +77,4 @@ "sudo-prompt": "^9.2.1", "tmp": "^0.2.3" } -} +} \ No newline at end of file