mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Optimize getCommandsInPath, restore cache
Changes: - Fix cache mechanism as pathValue never got stored - Cache labels instead of returning empty set - Walking each directory in separate promise and await via Promise.all - Don't create a promise on Windows when checking exe Fixes #239396
This commit is contained in:
@@ -6,11 +6,15 @@
|
||||
import { osIsWindows } from './os';
|
||||
import * as fs from 'fs/promises';
|
||||
|
||||
export async function isExecutable(filePath: string, configuredWindowsExecutableExtensions?: { [key: string]: boolean | undefined } | undefined): Promise<boolean> {
|
||||
export function isExecutable(filePath: string, configuredWindowsExecutableExtensions?: { [key: string]: boolean | undefined } | undefined): Promise<boolean> | boolean {
|
||||
if (osIsWindows()) {
|
||||
const resolvedWindowsExecutableExtensions = resolveWindowsExecutableExtensions(configuredWindowsExecutableExtensions);
|
||||
return resolvedWindowsExecutableExtensions.find(ext => filePath.endsWith(ext)) !== undefined;
|
||||
}
|
||||
return isExecutableUnix(filePath);
|
||||
}
|
||||
|
||||
export async function isExecutableUnix(filePath: string): Promise<boolean> {
|
||||
try {
|
||||
const stats = await fs.stat(filePath);
|
||||
// On macOS/Linux, check if the executable bit is set
|
||||
|
||||
Reference in New Issue
Block a user