Skip to content

Commit 952da81

Browse files
CopilotBernardXiong
andcommitted
refactor: Extract terminal menuconfig fallback logic to reduce duplication
Co-authored-by: BernardXiong <[email protected]>
1 parent fbc23b0 commit 952da81

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/project/cmd.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ export function fastBuildProject(arg: any) {
2727
return;
2828
}
2929

30+
/**
31+
* Helper function to execute terminal-based menuconfig for a BSP project
32+
* @param bspPath The path to the BSP project
33+
*/
34+
function executeTerminalMenuconfig(bspPath: string) {
35+
let cmd = 'scons -C ' + bspPath + ' --menuconfig';
36+
executeCommand(cmd);
37+
}
38+
3039
export function configProject(arg: any) {
3140
if (arg) {
3241
const menuconfigMethod = getMenuconfigMethod();
@@ -48,17 +57,15 @@ export function configProject(arg: any) {
4857
doc => {
4958
vscode.window.showTextDocument(doc);
5059
},
51-
(error: Error) => {
60+
error => {
5261
vscode.window.showErrorMessage(`Failed to open Kconfig file: ${error.message}`);
5362
// Fallback to terminal on error
54-
let cmd = 'scons -C ' + arg.fn + ' --menuconfig';
55-
executeCommand(cmd);
63+
executeTerminalMenuconfig(arg.fn);
5664
}
5765
);
5866
} else {
5967
// Fallback to terminal if Kconfig doesn't exist
60-
let cmd = 'scons -C ' + arg.fn + ' --menuconfig';
61-
executeCommand(cmd);
68+
executeTerminalMenuconfig(arg.fn);
6269
}
6370
}
6471
else {
@@ -68,8 +75,7 @@ export function configProject(arg: any) {
6875
}
6976
} else {
7077
// For terminal-based menuconfig
71-
let cmd = 'scons -C ' + arg.fn + ' --menuconfig';
72-
executeCommand(cmd);
78+
executeTerminalMenuconfig(arg.fn);
7379
}
7480
}
7581

0 commit comments

Comments
 (0)