File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,14 @@ interface ServerCancellationToken {
9
9
}
10
10
11
11
function pipeExists ( name : string ) : boolean {
12
- try {
13
- fs . statSync ( name ) ;
14
- return true ;
15
- }
16
- catch ( e ) {
17
- return false ;
18
- }
12
+ // Unlike statSync, existsSync doesn't throw an exception if the target doesn't exist.
13
+ // A comment in the node code suggests they're stuck with that decision for back compat
14
+ // (https://github.com/nodejs/node/blob/9da241b600182a9ff400f6efc24f11a6303c27f7/lib/fs.js#L222).
15
+ // Caveat: If a named pipe does exist, the first call to existsSync will return true, as for
16
+ // statSync. Subsequent calls will return false, whereas statSync would throw an exception
17
+ // indicating that the pipe was busy. The difference is immaterial, since our statSync
18
+ // implementation returned false from its catch block.
19
+ return fs . existsSync ( name ) ;
19
20
}
20
21
21
22
function createCancellationToken ( args : string [ ] ) : ServerCancellationToken {
You can’t perform that action at this time.
0 commit comments