@@ -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
}
@@ -153,11 +127,7 @@ class Watcher {
153
127
private cleanFiles ( ) : Promise < string [ ] > {
154
128
console . log ( "[Watcher]" , "Cleaning files from previous builds..." )
155
129
156
- return del ( [
157
- "out/**/*" ,
158
- // Included because the cache can sometimes enter bad state when debugging compiled files.
159
- ".cache/**/*" ,
160
- ] )
130
+ return del ( [ "out/**/*" ] )
161
131
}
162
132
163
133
/**
@@ -166,31 +136,22 @@ class Watcher {
166
136
*/
167
137
private emitCompilationStats ( ) : Promise < void > {
168
138
const stats : CompilationStats = {
169
- status : this . vscodeCompileStatus ,
170
139
lastCompiledAt : new Date ( ) ,
171
140
}
172
141
173
- this . log ( "Writing watcher stats..." )
142
+ console . log ( "Writing watcher stats..." )
174
143
return fs . writeFile ( this . paths . compilationStatsFile , JSON . stringify ( stats , null , 2 ) )
175
144
}
176
145
177
- private log ( ...entries : string [ ] ) {
178
- process . stdout . write ( entries . join ( " " ) )
179
- }
180
-
181
146
private dispose ( code : number | null ) : void {
182
147
for ( const [ processName , devProcess ] of Object . entries ( this . compilers ) ) {
183
- this . log ( `[${ processName } ]` , "Killing...\n" )
148
+ console . log ( `[${ processName } ]` , "Killing...\n" )
184
149
devProcess ?. removeAllListeners ( )
185
150
devProcess ?. kill ( )
186
151
}
187
152
process . exit ( typeof code === "number" ? code : 0 )
188
153
}
189
154
190
- private get hasVerboseLogging ( ) {
191
- return process . argv . includes ( "--log" )
192
- }
193
-
194
155
//#endregion
195
156
}
196
157
0 commit comments