Skip to content

Commit

Permalink
Remove sync file operation to unblock ext host (microsoft/vscode-pyth…
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Feb 29, 2024
1 parent 7713a1c commit d287ae9
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
isParentPath,
pathExists,
pathExistsSync,
readFileSync,
readFile,
shellExecute,
} from '../externalDependencies';
import { getEnvironmentDirFromPath } from '../commonUtils';
Expand Down Expand Up @@ -63,7 +63,7 @@ async function isLocalPoetryEnvironment(interpreterPath: string): Promise<boolea
return false;
}
const project = path.dirname(envDir);
if (!hasValidPyprojectToml(project)) {
if (!(await hasValidPyprojectToml(project))) {
return false;
}
// The assumption is that we need to be able to run poetry CLI for an environment in order to mark it as poetry.
Expand Down Expand Up @@ -126,7 +126,7 @@ export class Poetry {
*/
public static async getPoetry(cwd: string): Promise<Poetry | undefined> {
// Following check should be performed synchronously so we trigger poetry execution as soon as possible.
if (!hasValidPyprojectToml(cwd)) {
if (!(await hasValidPyprojectToml(cwd))) {
// This check is not expensive and may change during a session, so we need not cache it.
return undefined;
}
Expand Down Expand Up @@ -325,12 +325,12 @@ export async function isPoetryEnvironmentRelatedToFolder(
*
* @param folder Folder to look for pyproject.toml file in.
*/
function hasValidPyprojectToml(folder: string): boolean {
async function hasValidPyprojectToml(folder: string): Promise<boolean> {
const pyprojectToml = path.join(folder, 'pyproject.toml');
if (!pathExistsSync(pyprojectToml)) {
return false;
}
const content = readFileSync(pyprojectToml);
const content = await readFile(pyprojectToml);
if (!content.includes('[tool.poetry]')) {
return false;
}
Expand Down

0 comments on commit d287ae9

Please sign in to comment.