@@ -5,7 +5,7 @@ import { collectExtractProps } from './requests/collectExtractProps';
55import { getComponentEvents , getComponentNames , getComponentProps , getElementAttrs , getTemplateContextProps } from './requests/componentInfos' ;
66import { getPropertiesAtLocation } from './requests/getPropertiesAtLocation' ;
77import { getQuickInfoAtPosition } from './requests/getQuickInfoAtPosition' ;
8- import { NamedPipeServer , connect , pipeTable } from './utils' ;
8+ import { NamedPipeServer , connect , readPipeTable , updatePipeTable } from './utils' ;
99import type { FileRegistry , VueCompilerOptions } from '@vue/language-core' ;
1010
1111export interface Request {
@@ -103,16 +103,13 @@ export function startNamedPipeServer(
103103
104104 cleanupPipeTable ( ) ;
105105
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 ( ) ;
110107 table . push ( {
111108 path : pipeFile ,
112109 serverKind,
113110 currentDirectory,
114111 } ) ;
115- fs . writeFileSync ( pipeTable , JSON . stringify ( table , undefined , 2 ) ) ;
112+ updatePipeTable ( table ) ;
116113
117114 try {
118115 fs . unlinkSync ( pipeFile ) ;
@@ -122,18 +119,15 @@ export function startNamedPipeServer(
122119}
123120
124121function 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 ( ) ) {
129123 connect ( server . path ) . then ( client => {
130124 if ( client ) {
131125 client . end ( ) ;
132126 }
133127 else {
134- let table : NamedPipeServer [ ] = JSON . parse ( fs . readFileSync ( pipeTable , 'utf8' ) ) ;
128+ let table : NamedPipeServer [ ] = readPipeTable ( ) ;
135129 table = table . filter ( item => item . path !== server . path ) ;
136- fs . writeFileSync ( pipeTable , JSON . stringify ( table , undefined , 2 ) ) ;
130+ updatePipeTable ( table ) ;
137131 }
138132 } ) ;
139133 }
0 commit comments