@@ -2,7 +2,7 @@ import { spawn, fork, ChildProcess } from "child_process"
2
2
import del from "del"
3
3
import { promises as fs } from "fs"
4
4
import * as path from "path"
5
- import { CompilationStats , onLine , OnLineCallback , VSCodeCompileStatus } from "../../src/node/util"
5
+ import { CompilationStats , onLine , OnLineCallback } from "../../src/node/util"
6
6
7
7
interface DevelopmentCompilers {
8
8
[ key : string ] : ChildProcess | undefined
@@ -52,24 +52,18 @@ class Watcher {
52
52
plugins : this . paths . pluginDir ? spawn ( "yarn" , [ "build" , "--watch" ] , { cwd : this . paths . pluginDir } ) : undefined ,
53
53
}
54
54
55
- private vscodeCompileStatus = VSCodeCompileStatus . Loading
56
-
57
55
public async initialize ( ) : Promise < void > {
58
56
for ( const event of [ "SIGINT" , "SIGTERM" ] ) {
59
57
process . on ( event , ( ) => this . dispose ( 0 ) )
60
58
}
61
59
62
- if ( ! this . hasVerboseLogging ) {
63
- console . log ( "\n[Watcher]" , "Compiler logs will be minimal. Pass --log to show all output." )
64
- }
65
-
66
60
this . cleanFiles ( )
67
61
68
62
for ( const [ processName , devProcess ] of Object . entries ( this . compilers ) ) {
69
63
if ( ! devProcess ) continue
70
64
71
65
devProcess . on ( "exit" , ( code ) => {
72
- this . log ( `[${ processName } ]` , "Terminated unexpectedly" )
66
+ console . log ( `[${ processName } ]` , "Terminated unexpectedly" )
73
67
this . dispose ( code )
74
68
} )
75
69
@@ -91,33 +85,14 @@ class Watcher {
91
85
//#region Line Parsers
92
86
93
87
private parseVSCodeLine : OnLineCallback = ( strippedLine , originalLine ) => {
94
- if ( ! strippedLine . includes ( "watch-extensions" ) || this . hasVerboseLogging ) {
95
- console . log ( "[VS Code]" , originalLine )
96
- }
88
+ if ( ! strippedLine . length ) return
89
+
90
+ console . log ( "[VS Code]" , originalLine )
97
91
98
- switch ( this . vscodeCompileStatus ) {
99
- case VSCodeCompileStatus . Loading :
100
- // Wait for watch-client since "Finished compilation" will appear multiple
101
- // times before the client starts building.
102
- if ( strippedLine . includes ( "Starting 'watch-client'" ) ) {
103
- console . log ( "[VS Code] 🚧 Compiling 🚧" , "(This may take a moment!)" )
104
- this . vscodeCompileStatus = VSCodeCompileStatus . Compiling
105
- }
106
- break
107
- case VSCodeCompileStatus . Compiling :
108
- if ( strippedLine . includes ( "Finished compilation" ) ) {
109
- console . log ( "[VS Code] ✨ Finished compiling! ✨" , "(Refresh your web browser ♻️)" )
110
- this . vscodeCompileStatus = VSCodeCompileStatus . Compiled
111
-
112
- this . emitCompilationStats ( )
113
- this . reloadWebServer ( )
114
- }
115
- break
116
- case VSCodeCompileStatus . Compiled :
117
- console . log ( "[VS Code] 🔔 Finished recompiling! 🔔" , "(Refresh your web browser ♻️)" )
118
- this . emitCompilationStats ( )
119
- this . reloadWebServer ( )
120
- break
92
+ if ( strippedLine . includes ( "Finished compilation with" ) ) {
93
+ console . log ( "[VS Code] ✨ Finished compiling! ✨" , "(Refresh your web browser ♻️)" )
94
+ this . emitCompilationStats ( )
95
+ this . reloadWebServer ( )
121
96
}
122
97
}
123
98
@@ -128,7 +103,6 @@ class Watcher {
128
103
129
104
if ( strippedLine . includes ( "Watching for file changes" ) ) {
130
105
console . log ( "[Compiler][Code Server]" , "Finished compiling!" , "(Refresh your web browser ♻️)" )
131
-
132
106
this . reloadWebServer ( )
133
107
}
134
108
}
@@ -155,8 +129,6 @@ class Watcher {
155
129
156
130
return del ( [
157
131
"out/**/*" ,
158
- // Included because the cache can sometimes enter bad state when debugging compiled files.
159
- ".cache/**/*" ,
160
132
] )
161
133
}
162
134
@@ -166,31 +138,22 @@ class Watcher {
166
138
*/
167
139
private emitCompilationStats ( ) : Promise < void > {
168
140
const stats : CompilationStats = {
169
- status : this . vscodeCompileStatus ,
170
141
lastCompiledAt : new Date ( ) ,
171
142
}
172
143
173
- this . log ( "Writing watcher stats..." )
144
+ console . log ( "Writing watcher stats..." )
174
145
return fs . writeFile ( this . paths . compilationStatsFile , JSON . stringify ( stats , null , 2 ) )
175
146
}
176
147
177
- private log ( ...entries : string [ ] ) {
178
- process . stdout . write ( entries . join ( " " ) )
179
- }
180
-
181
148
private dispose ( code : number | null ) : void {
182
149
for ( const [ processName , devProcess ] of Object . entries ( this . compilers ) ) {
183
- this . log ( `[${ processName } ]` , "Killing...\n" )
150
+ console . log ( `[${ processName } ]` , "Killing...\n" )
184
151
devProcess ?. removeAllListeners ( )
185
152
devProcess ?. kill ( )
186
153
}
187
154
process . exit ( typeof code === "number" ? code : 0 )
188
155
}
189
156
190
- private get hasVerboseLogging ( ) {
191
- return process . argv . includes ( "--log" )
192
- }
193
-
194
157
//#endregion
195
158
}
196
159
0 commit comments