From ebff505827f52686b3d12cdefbe1273e4f4fc327 Mon Sep 17 00:00:00 2001 From: therainisme Date: Tue, 14 Jan 2025 09:42:49 +0800 Subject: [PATCH] Exclude 'unused-images' and 'node_modules' directories during file search (#7) --- CHANGELOG.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- src/extension.ts | 5 ++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d193d29..a385c80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 1.1.1 + +- Fix regex to handle filenames with spaces correctly (#6) +- Exclude 'unused-images' and 'node_modules' directories during file search (#7) + ## 1.1.0 - Implement concurrent markdown scanning and parallel image movement. diff --git a/package-lock.json b/package-lock.json index b815902..9d11674 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "clear-markdown-unused-images", - "version": "1.1.0", + "version": "1.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "clear-markdown-unused-images", - "version": "1.1.0", + "version": "1.1.1", "devDependencies": { "@types/mocha": "^10.0.6", "@types/node": "18.x", diff --git a/package.json b/package.json index 259c705..b27a232 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "clear-markdown-unused-images", "displayName": "Clear Markdown Unused Images", "description": "This extension moves unused images in Markdown files to the 'unused-images' folder.", - "version": "1.1.0", + "version": "1.1.1", "engines": { "vscode": "^1.85.2" }, diff --git a/src/extension.ts b/src/extension.ts index bf7f1d6..9ae1aa8 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -23,7 +23,10 @@ export function activate(context: vscode.ExtensionContext) { try { // Step 1: Find all image files in the workspace progress.report({ message: 'Finding image files...', increment: 5 }); - const images = await vscode.workspace.findFiles('**/*.{png,jpg,jpeg,gif,bmp,tiff,webp,svg}'); + const images = await vscode.workspace.findFiles( + '**/*.{png,jpg,jpeg,gif,bmp,tiff,webp,svg}', + '{**/unused-images/**,**/node_modules/**}' // Exclude unused-images and node_modules directories + ); const imagePathsSet = new Set(images.map(image => path.normalize(image.fsPath))); const totalImages = imagePathsSet.size;