@@ -37,6 +37,7 @@ class Watcher {
37
37
38
38
const vscode = cp . spawn ( "yarn" , [ "watch" ] , { cwd : this . vscodeSourcePath } )
39
39
const tsc = cp . spawn ( "tsc" , [ "--watch" , "--pretty" , "--preserveWatchOutput" ] , { cwd : this . rootPath } )
40
+ const plugin = cp . spawn ( "yarn" , [ "build" , "--watch" ] , { cwd : process . env . PLUGIN_DIR } )
40
41
const bundler = this . createBundler ( )
41
42
42
43
const cleanup = ( code ?: number | null ) : void => {
@@ -48,6 +49,10 @@ class Watcher {
48
49
tsc . removeAllListeners ( )
49
50
tsc . kill ( )
50
51
52
+ Watcher . log ( "killing plugin" )
53
+ plugin . removeAllListeners ( )
54
+ plugin . kill ( )
55
+
51
56
if ( server ) {
52
57
Watcher . log ( "killing server" )
53
58
server . removeAllListeners ( )
@@ -69,6 +74,10 @@ class Watcher {
69
74
Watcher . log ( "tsc terminated unexpectedly" )
70
75
cleanup ( code )
71
76
} )
77
+ plugin . on ( "exit" , ( code ) => {
78
+ Watcher . log ( "plugin terminated unexpectedly" )
79
+ cleanup ( code )
80
+ } )
72
81
const bundle = bundler . bundle ( ) . catch ( ( ) => {
73
82
Watcher . log ( "parcel watcher terminated unexpectedly" )
74
83
cleanup ( 1 )
@@ -82,6 +91,7 @@ class Watcher {
82
91
83
92
vscode . stderr . on ( "data" , ( d ) => process . stderr . write ( d ) )
84
93
tsc . stderr . on ( "data" , ( d ) => process . stderr . write ( d ) )
94
+ plugin . stderr . on ( "data" , ( d ) => process . stderr . write ( d ) )
85
95
86
96
// From https://github.com/chalk/ansi-regex
87
97
const pattern = [
@@ -140,6 +150,16 @@ class Watcher {
140
150
bundle . then ( restartServer )
141
151
}
142
152
} )
153
+
154
+ onLine ( plugin , ( line , original ) => {
155
+ // tsc outputs blank lines; skip them.
156
+ if ( line !== "" ) {
157
+ console . log ( "[plugin]" , original )
158
+ }
159
+ if ( line . includes ( "Watching for file changes" ) ) {
160
+ bundle . then ( restartServer )
161
+ }
162
+ } )
143
163
}
144
164
145
165
private createBundler ( out = "dist" ) : Bundler {
0 commit comments