File tree 3 files changed +9
-10
lines changed
3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -211,7 +211,7 @@ export class PowerShellProcess {
211
211
212
212
// Check every 2 seconds
213
213
for ( let i = numOfTries ; i > 0 ; i -- ) {
214
- if ( utils . checkIfFileExists ( this . sessionFilePath . fsPath ) ) {
214
+ if ( await utils . checkIfFileExists ( this . sessionFilePath ) ) {
215
215
this . log . write ( "Session file found" ) ;
216
216
const sessionDetails = PowerShellProcess . readSessionFile ( this . sessionFilePath ) ;
217
217
PowerShellProcess . deleteSessionFile ( this . sessionFilePath ) ;
Original file line number Diff line number Diff line change @@ -317,7 +317,7 @@ export async function validateCwdSetting(): Promise<string> {
317
317
let cwd : string = vscode . workspace . getConfiguration ( utils . PowerShellLanguageId ) . get < string > ( "cwd" , null ) ;
318
318
319
319
// Only use the cwd setting if it exists.
320
- if ( utils . checkIfDirectoryExists ( cwd ) ) {
320
+ if ( await utils . checkIfDirectoryExists ( cwd ) ) {
321
321
return cwd ;
322
322
} else {
323
323
// Otherwise use a workspace folder, prompting if necessary.
@@ -333,7 +333,7 @@ export async function validateCwdSetting(): Promise<string> {
333
333
}
334
334
// If there were no workspace folders, or somehow they don't exist, use
335
335
// the home directory.
336
- if ( cwd === undefined || ! utils . checkIfDirectoryExists ( cwd ) ) {
336
+ if ( cwd === undefined || ! await utils . checkIfDirectoryExists ( cwd ) ) {
337
337
return os . homedir ( ) ;
338
338
}
339
339
return cwd ;
Original file line number Diff line number Diff line change @@ -37,20 +37,19 @@ export function getPipePath(pipeName: string) {
37
37
}
38
38
}
39
39
40
- export function checkIfFileExists ( filePath : string ) : boolean {
40
+ export async function checkIfFileExists ( filePath : vscode . Uri ) : Promise < boolean > {
41
41
try {
42
- fs . accessSync ( filePath , fs . constants . R_OK ) ;
43
- return true ;
42
+ const stat : vscode . FileStat = await vscode . workspace . fs . stat ( filePath ) ;
43
+ return stat . type === vscode . FileType . File ;
44
44
} catch ( e ) {
45
45
return false ;
46
46
}
47
47
}
48
48
49
- export function checkIfDirectoryExists ( directoryPath : string ) : boolean {
49
+ export async function checkIfDirectoryExists ( directoryPath : string ) : Promise < boolean > {
50
50
try {
51
- // tslint:disable-next-line:no-bitwise
52
- fs . accessSync ( directoryPath , fs . constants . R_OK | fs . constants . O_DIRECTORY ) ;
53
- return true ;
51
+ const stat : vscode . FileStat = await vscode . workspace . fs . stat ( vscode . Uri . file ( directoryPath ) ) ;
52
+ return stat . type === vscode . FileType . Directory ;
54
53
} catch ( e ) {
55
54
return false ;
56
55
}
You can’t perform that action at this time.
0 commit comments