From 7cddcee9518ea6bb53d1042fce138660295f72bd Mon Sep 17 00:00:00 2001 From: Liangcheng Juves Date: Sun, 15 May 2022 12:07:54 +0800 Subject: [PATCH] Fix the problem that the `Developer Prompt for VS 2022` profile could not be loaded --- tabby-local/src/shells/vs.ts | 42 +++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/tabby-local/src/shells/vs.ts b/tabby-local/src/shells/vs.ts index addf52d9..d0a399ad 100644 --- a/tabby-local/src/shells/vs.ts +++ b/tabby-local/src/shells/vs.ts @@ -27,30 +27,32 @@ export class VSDevToolsProvider extends ShellProvider { return [] } - const parentPath = path.join(process.env['programfiles(x86)'] ?? 'C:\\Program Files (x86', 'Microsoft Visual Studio') - - try { - await fs.stat(parentPath) - } catch { - return [] - } + const x86ParentPath = path.join(process.env['programfiles(x86)'] ?? 'C:\\Program Files (x86)', 'Microsoft Visual Studio') + const x64ParentPath = path.join(process.env['programfiles'] ?? 'C:\\Program Files', 'Microsoft Visual Studio') const result: Shell[] = [] - for (const version of await fs.readdir(parentPath)) { - const bat = path.join(parentPath, version, 'Community\\Common7\\Tools\\VsDevCmd.bat') + for (const parentPath of [x86ParentPath, x64ParentPath]) { try { - await fs.stat(bat) - } catch { - continue + await fs.stat(parentPath) + for (const version of await fs.readdir(parentPath)) { + const bat = path.join(parentPath, version, 'Community\\Common7\\Tools\\VsDevCmd.bat') + try { + await fs.stat(bat) + } catch { + continue + } + result.push({ + id: `vs-cmd-${version}`, + name: `Developer Prompt for VS ${version}`, + command: 'cmd.exe', + args: ['/k', bat], + icon: vsIconMap[version], + env: {}, + }) + } + } catch (_) { + // Ignore } - result.push({ - id: `vs-cmd-${version}`, - name: `Developer Prompt for VS ${version}`, - command: 'cmd.exe', - args: ['/k', bat], - icon: vsIconMap[version], - env: {}, - }) } return result