|
| 1 | +const vscode = require("vscode"); |
| 2 | + |
| 3 | +/** |
| 4 | + * @param {vscode.ExtensionContext} context |
| 5 | + */ |
| 6 | +async function activate(context) { |
| 7 | + let disposableFindUnusedAssets = vscode.commands.registerCommand( |
| 8 | + "FUA.findUnusedAssets", |
| 9 | + await findUnusedAssets |
| 10 | + ); |
| 11 | + let disposableRemoveUnusedAssets = vscode.commands.registerCommand( |
| 12 | + "FUA.removeUnusedAssets", |
| 13 | + await removeUnusedAssets |
| 14 | + ); |
| 15 | + |
| 16 | + context.subscriptions.push(disposableFindUnusedAssets); |
| 17 | + context.subscriptions.push(disposableRemoveUnusedAssets); |
| 18 | +} |
| 19 | + |
| 20 | +async function findUnusedAssets() { |
| 21 | + if (await isFindable()) { |
| 22 | + vscode.window.showInformationMessage("works!"); |
| 23 | + let workspacePath = vscode.workspace.workspaceFolders[0].uri.path; |
| 24 | + let workspaceFsPath = vscode.workspace.workspaceFolders[0].uri.fsPath; |
| 25 | + // Continue with your logic here |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +async function isFindable() { |
| 30 | + if (isWorkspaceOpen()) { |
| 31 | + return await hasSrcFolder(); |
| 32 | + } else return false; |
| 33 | +} |
| 34 | + |
| 35 | +async function hasSrcFolder() { |
| 36 | + const files = await vscode.workspace.findFiles("src/**", "", 1); |
| 37 | + if (!files || files.length === 0) { |
| 38 | + vscode.window.showInformationMessage("src folder not found."); |
| 39 | + return false; |
| 40 | + } else return true; |
| 41 | +} |
| 42 | + |
| 43 | +function isWorkspaceOpen() { |
| 44 | + if (!vscode.workspace.workspaceFolders) { |
| 45 | + vscode.window.showErrorMessage("Please open a workspace/folder for using this command."); |
| 46 | + return false; |
| 47 | + } else return true; |
| 48 | +} |
| 49 | + |
| 50 | +async function removeUnusedAssets() {} |
| 51 | + |
| 52 | +function deactivate() {} |
| 53 | + |
| 54 | +module.exports = { |
| 55 | + activate, |
| 56 | + deactivate, |
| 57 | +}; |
0 commit comments