nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: oliverschwendener/ueli
Pull request #1355 (2025-02-08 10:49:00)

Fixed invocation of Everything CLI
Fixed invocation of Everything CLI (part of #503)


Patch:
diff --git a/src/main/Extensions/FileSearch/Windows/EverythingFileSearcher.ts b/src/main/Extensions/FileSearch/Windows/EverythingFileSearcher.ts
index 3d48342d..9d079020 100644
--- a/src/main/Extensions/FileSearch/Windows/EverythingFileSearcher.ts
+++ b/src/main/Extensions/FileSearch/Windows/EverythingFileSearcher.ts
@@ -23,8 +23,9 @@ export class EverythingFileSearcher implements FileSearcher {
             return [];
         }
 
+        const escapedSearchTerm = EverythingFileSearcher.escapeSearchTerm(searchTerm);
         const stdout = await this.commandlineUtility.executeCommand(
-            `cmd /c chcp 65001>nul && "${everythingCliFilePath}" -max-results ${maxSearchResultCount} ${searchTerm}`,
+            `cmd /c chcp 65001>nul && "${everythingCliFilePath}" -max-results ${maxSearchResultCount} ${escapedSearchTerm}`,
         );
 
         return stdout
@@ -32,4 +33,8 @@ export class EverythingFileSearcher implements FileSearcher {
             .map((line) => normalize(line).trim())
             .filter((f) => f !== ".");
     }
+
+    public static escapeSearchTerm(searchTerm: string): string {
+        return searchTerm.replace(/([\\&|><^])/g, "^$1");
+    }
 }


Test patch:
diff --git a/src/main/Extensions/FileSearch/FileSearch.test.ts b/src/main/Extensions/FileSearch/FileSearch.test.ts
new file mode 100644
index 00000000..f8f1b9ae
--- /dev/null
+++ b/src/main/Extensions/FileSearch/FileSearch.test.ts
@@ -0,0 +1,22 @@
+import { describe, expect, it } from "vitest";
+import { EverythingFileSearcher } from "./Windows/EverythingFileSearcher";
+
+describe(EverythingFileSearcher, () => {
+    describe(EverythingFileSearcher.escapeSearchTerm, () => {
+        it.each([
+            ["test", "test"],
+            ["ext:pdf test", "ext:pdf test"],
+            ["size:>1MB", "size:^>1MB"],
+            ["size:<1MB", "size:^<1MB"],
+            ["ext:txt -s", "ext:txt -s"],
+            [
+                "-size -dm -sizecolor 0x0d -dmcolor 0x0b -save-settings",
+                "-size -dm -sizecolor 0x0d -dmcolor 0x0b -save-settings",
+            ],
+            ["\\&|><^", "^\\^&^|^>^<^^"],
+        ])("should escape arguments with a regex", (searchTerm, expectedPattern) => {
+            const escapedSearchTerm = searchTerm.replace(/([\\&|><^])/g, "^$1");
+            expect(escapedSearchTerm).toMatch(expectedPattern);
+        });
+    });
+});
Repository: oliverschwendener/ueli
Pull request #1414 (2025-04-15 06:48:26)

feat(FileSystemUtility): add `writeFile`
Title says it all


Patch:
diff --git a/src/main/Core/FileSystemUtility/Contract/FileSystemUtility.ts b/src/main/Core/FileSystemUtility/Contract/FileSystemUtility.ts
index 43b2d3f5..11e758a0 100644
--- a/src/main/Core/FileSystemUtility/Contract/FileSystemUtility.ts
+++ b/src/main/Core/FileSystemUtility/Contract/FileSystemUtility.ts
@@ -12,6 +12,7 @@ export interface FileSystemUtility {
     readDirectorySync(folderPath: string, recursive?: boolean): string[];
     removeFile(filePath: string): Promise<void>;
     removeFileSync(filePath: string): void;
+    writeFile(data: Buffer, filePath: string): Promise<void>;
     writeTextFile(data: string, filePath: string): Promise<void>;
     writeJsonFile<T>(data: T, filePath: string): Promise<void>;
     writeJsonFileSync<T>(data: T, filePath: string): void;
diff --git a/src/main/Core/FileSystemUtility/NodeJsFileSystemUtility.ts b/src/main/Core/FileSystemUtility/NodeJsFileSystemUtility.ts
index 322f1ced..93e35849 100644
--- a/src/main/Core/FileSystemUtility/NodeJsFileSystemUtility.ts
+++ b/src/main/Core/FileSystemUtility/NodeJsFileSystemUtility.ts
@@ -1,5 +1,5 @@
 import { access, accessSync, existsSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "fs";
-import { copyFile, mkdir, readdir, readFile, rm, writeFile } from "fs/promises";
+import { copyFile, writeFile as fsWriteFile, mkdir, readdir, readFile, rm } from "fs/promises";
 import { join } from "path";
 import type { FileSystemUtility } from "./Contract";
 
@@ -43,8 +43,12 @@ export class NodeJsFileSystemUtility implements FileSystemUtility {
         rmSync(filePath, { recursive: true });
     }
 
+    public async writeFile(data: Buffer, filePath: string): Promise<void> {
+        await fsWriteFile(filePath, data);
+    }
+
     public async writeTextFile(data: string, filePath: string): Promise<void> {
-        await writeFile(filePath, data, "utf-8");
+        await fsWriteFile(filePath, data, "utf-8");
     }
 
     public async writeJsonFile<T>(data: T, filePath: string): Promise<void> {


Test patch:
diff --git a/src/main/Core/FileSystemUtility/NodeJsFileSystemUtility.test.ts b/src/main/Core/FileSystemUtility/NodeJsFileSystemUtility.test.ts
index 46415742..d3e6ad96 100644
--- a/src/main/Core/FileSystemUtility/NodeJsFileSystemUtility.test.ts
+++ b/src/main/Core/FileSystemUtility/NodeJsFileSystemUtility.test.ts
@@ -365,4 +365,16 @@ describe(NodeJsFileSystemUtility, () => {
             expect(actual).toBe(content);
         });
     });
+
+    describe(NodeJsFileSystemUtility.prototype.writeFile, () => {
+        it("should write a buffer to a file", async () => {
+            const fileSystemUtility = new NodeJsFileSystemUtility();
+            const filePath = join(tempFolderPath, "file.txt");
+            const buffer = Buffer.from("test", "utf-8");
+
+            await fileSystemUtility.writeFile(buffer, filePath);
+
+            expect(await fileSystemUtility.readFile(filePath)).toEqual(buffer);
+        });
+    });
 });