@@ -37,7 +37,9 @@ 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
+ const plugin = process . env . PLUGIN_DIR
41
+ ? cp . spawn ( "yarn" , [ "build" , "--watch" ] , { cwd : process . env . PLUGIN_DIR } )
42
+ : undefined
41
43
const bundler = this . createBundler ( )
42
44
43
45
const cleanup = ( code ?: number | null ) : void => {
@@ -49,9 +51,11 @@ class Watcher {
49
51
tsc . removeAllListeners ( )
50
52
tsc . kill ( )
51
53
52
- Watcher . log ( "killing plugin" )
53
- plugin . removeAllListeners ( )
54
- plugin . kill ( )
54
+ if ( plugin ) {
55
+ Watcher . log ( "killing plugin" )
56
+ plugin . removeAllListeners ( )
57
+ plugin . kill ( )
58
+ }
55
59
56
60
if ( server ) {
57
61
Watcher . log ( "killing server" )
@@ -74,10 +78,12 @@ class Watcher {
74
78
Watcher . log ( "tsc terminated unexpectedly" )
75
79
cleanup ( code )
76
80
} )
77
- plugin . on ( "exit" , ( code ) => {
78
- Watcher . log ( "plugin terminated unexpectedly" )
79
- cleanup ( code )
80
- } )
81
+ if ( plugin ) {
82
+ plugin . on ( "exit" , ( code ) => {
83
+ Watcher . log ( "plugin terminated unexpectedly" )
84
+ cleanup ( code )
85
+ } )
86
+ }
81
87
const bundle = bundler . bundle ( ) . catch ( ( ) => {
82
88
Watcher . log ( "parcel watcher terminated unexpectedly" )
83
89
cleanup ( 1 )
@@ -91,7 +97,9 @@ class Watcher {
91
97
92
98
vscode . stderr . on ( "data" , ( d ) => process . stderr . write ( d ) )
93
99
tsc . stderr . on ( "data" , ( d ) => process . stderr . write ( d ) )
94
- plugin . stderr . on ( "data" , ( d ) => process . stderr . write ( d ) )
100
+ if ( plugin ) {
101
+ plugin . stderr . on ( "data" , ( d ) => process . stderr . write ( d ) )
102
+ }
95
103
96
104
// From https://github.com/chalk/ansi-regex
97
105
const pattern = [
@@ -151,15 +159,17 @@ class Watcher {
151
159
}
152
160
} )
153
161
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
- } )
162
+ if ( plugin ) {
163
+ onLine ( plugin , ( line , original ) => {
164
+ // tsc outputs blank lines; skip them.
165
+ if ( line !== "" ) {
166
+ console . log ( "[plugin]" , original )
167
+ }
168
+ if ( line . includes ( "Watching for file changes" ) ) {
169
+ bundle . then ( restartServer )
170
+ }
171
+ } )
172
+ }
163
173
}
164
174
165
175
private createBundler ( out = "dist" ) : Bundler {
0 commit comments