1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-09-11 13:13:59 +03:00

Fix the problem that the Developer Prompt for VS 2022 profile could not be loaded

This commit is contained in:
Liangcheng Juves 2022-05-15 12:07:54 +08:00
parent fa2bbe39c4
commit 7cddcee951

View File

@ -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