From b7f2ee7233645e25986188be4d8133785da4a174 Mon Sep 17 00:00:00 2001 From: "samuel.gjabel" Date: Sat, 19 Oct 2024 14:55:31 +0700 Subject: [PATCH] chore: update to latest bun + add custom flag support --- packages/bun-vscode/package.json | 5 +++++ packages/bun-vscode/src/features/tests/index.ts | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/bun-vscode/package.json b/packages/bun-vscode/package.json index a52786cb6c5be..e8d0a310ffaa6 100644 --- a/packages/bun-vscode/package.json +++ b/packages/bun-vscode/package.json @@ -100,6 +100,11 @@ "type": "string", "default": "**/*.{test,spec}.{js,ts,tsx,jsx}", "description": "Glob pattern to match test files (e.g., **/*.test.{js,ts,tsx,jsx})" + }, + "bun.test.customFlag": { + "type": "string", + "default": "", + "description": "Custom flag added to the end of test command" } } }, diff --git a/packages/bun-vscode/src/features/tests/index.ts b/packages/bun-vscode/src/features/tests/index.ts index 380db21a5867f..9c54eb996bf3a 100644 --- a/packages/bun-vscode/src/features/tests/index.ts +++ b/packages/bun-vscode/src/features/tests/index.ts @@ -75,7 +75,8 @@ export function registerTestCodeLens(context: vscode.ExtensionContext) { const codeLensProvider = new TestCodeLensProvider(); // Get the user-defined file pattern from the settings, or use the default - // Setting is: bun.test.filePattern + // Setting is: + // bun.test.filePattern const pattern = vscode.workspace.getConfiguration("bun.test").get("filePattern", DEFAULT_FILE_PATTERN); const options = { scheme: "file", pattern }; @@ -102,10 +103,15 @@ let activeTerminal: vscode.Terminal | null = null; */ export function registerTestRunner(context: vscode.ExtensionContext) { + + // Register the "Run Test" command const runTestCommand = vscode.commands.registerCommand( "extension.bun.runTest", async (fileName?: string, testName?: string, watchMode: boolean = false) => { + + // Get custom flag + const customFlag = vscode.workspace.getConfiguration("bun.test").get("customFlag", ""); // When this command is called from the command palette, the fileName and testName arguments are not passed (commands in package.json) // so then fileName is taken from the active text editor and it run for the whole file. if (!fileName) { @@ -124,7 +130,7 @@ export function registerTestRunner(context: vscode.ExtensionContext) { activeTerminal.show(); const watchFlag = watchMode ? "--watch" : ""; const testNameIfExist = testName ? ` -t "${testName}"` : ""; - activeTerminal.sendText(`bun test ${fileName} ${testNameIfExist} ${watchFlag}`); + activeTerminal.sendText(`bun test ${fileName} ${testNameIfExist} ${watchFlag} ${customFlag}`); }, );