File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ export async function exists(path: string) {
17
17
}
18
18
}
19
19
20
+ export async function isFile ( path : string ) {
21
+ try {
22
+ const s = await fs . promises . stat ( path ) ;
23
+ return s . isFile ( ) ;
24
+ } catch {
25
+ return false ;
26
+ }
27
+ }
28
+
20
29
export function untildify ( path : string ) {
21
30
return path . replace ( / ^ ~ (? = $ | \/ | \\ ) / , homeDir ) ;
22
31
}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import * as fs from 'fs';
8
8
import * as path from 'path' ;
9
9
import SSHConfig , { Line , Section } from 'ssh-config' ;
10
10
import * as vscode from 'vscode' ;
11
- import { exists as fileExists } from '../common/files' ;
11
+ import { isFile } from '../common/files' ;
12
12
import { isWindows } from '../common/platform' ;
13
13
14
14
const systemSSHConfig = isWindows ? path . resolve ( process . env . ALLUSERSPROFILE || 'C:\\ProgramData' , 'ssh\\ssh_config' ) : '/etc/ssh/ssh_config' ;
@@ -28,12 +28,12 @@ export default class SSHConfiguration {
28
28
static async loadFromFS ( ) : Promise < SSHConfiguration > {
29
29
const sshConfigPath = getSSHConfigPath ( ) ;
30
30
let content = '' ;
31
- if ( await fileExists ( sshConfigPath ) ) {
31
+ if ( await isFile ( sshConfigPath ) ) {
32
32
content = ( await fs . promises . readFile ( sshConfigPath , 'utf8' ) ) . trim ( ) ;
33
33
}
34
34
const config = SSHConfig . parse ( content ) ;
35
35
36
- if ( await fileExists ( systemSSHConfig ) ) {
36
+ if ( await isFile ( systemSSHConfig ) ) {
37
37
content = ( await fs . promises . readFile ( systemSSHConfig , 'utf8' ) ) . trim ( ) ;
38
38
config . push ( ...SSHConfig . parse ( content ) ) ;
39
39
}
You can’t perform that action at this time.
0 commit comments