@@ -5,7 +5,7 @@ import { collectExtractProps } from './requests/collectExtractProps';
5
5
import { getComponentEvents , getComponentNames , getComponentProps , getElementAttrs , getTemplateContextProps } from './requests/componentInfos' ;
6
6
import { getPropertiesAtLocation } from './requests/getPropertiesAtLocation' ;
7
7
import { getQuickInfoAtPosition } from './requests/getQuickInfoAtPosition' ;
8
- import { NamedPipeServer , connect , pipeTable } from './utils' ;
8
+ import { NamedPipeServer , connect , readPipeTable , updatePipeTable } from './utils' ;
9
9
import type { FileRegistry , VueCompilerOptions } from '@vue/language-core' ;
10
10
11
11
export interface Request {
@@ -103,16 +103,13 @@ export function startNamedPipeServer(
103
103
104
104
cleanupPipeTable ( ) ;
105
105
106
- if ( ! fs . existsSync ( pipeTable ) ) {
107
- fs . writeFileSync ( pipeTable , JSON . stringify ( [ ] satisfies NamedPipeServer [ ] ) ) ;
108
- }
109
- const table : NamedPipeServer [ ] = JSON . parse ( fs . readFileSync ( pipeTable , 'utf8' ) ) ;
106
+ const table = readPipeTable ( ) ;
110
107
table . push ( {
111
108
path : pipeFile ,
112
109
serverKind,
113
110
currentDirectory,
114
111
} ) ;
115
- fs . writeFileSync ( pipeTable , JSON . stringify ( table , undefined , 2 ) ) ;
112
+ updatePipeTable ( table ) ;
116
113
117
114
try {
118
115
fs . unlinkSync ( pipeFile ) ;
@@ -122,18 +119,15 @@ export function startNamedPipeServer(
122
119
}
123
120
124
121
function cleanupPipeTable ( ) {
125
- if ( ! fs . existsSync ( pipeTable ) ) {
126
- return ;
127
- }
128
- for ( const server of JSON . parse ( fs . readFileSync ( pipeTable , 'utf8' ) ) ) {
122
+ for ( const server of readPipeTable ( ) ) {
129
123
connect ( server . path ) . then ( client => {
130
124
if ( client ) {
131
125
client . end ( ) ;
132
126
}
133
127
else {
134
- let table : NamedPipeServer [ ] = JSON . parse ( fs . readFileSync ( pipeTable , 'utf8' ) ) ;
128
+ let table : NamedPipeServer [ ] = readPipeTable ( ) ;
135
129
table = table . filter ( item => item . path !== server . path ) ;
136
- fs . writeFileSync ( pipeTable , JSON . stringify ( table , undefined , 2 ) ) ;
130
+ updatePipeTable ( table ) ;
137
131
}
138
132
} ) ;
139
133
}
0 commit comments