@@ -190,11 +190,11 @@ function getBscArgs(
190
190
) : Promise < Array < string > | RewatchCompilerArgs | null > {
191
191
const buildNinjaPath = path . resolve (
192
192
entry . project . rootPath ,
193
- "lib/bs/build.ninja"
193
+ c . buildNinjaPartialPath
194
194
) ;
195
195
const rewatchLockfile = path . resolve (
196
196
entry . project . workspaceRootPath ,
197
- "lib/rewatch.lock"
197
+ c . rewatchLockPartialPath
198
198
) ;
199
199
let buildSystem : "bsb" | "rewatch" | null = null ;
200
200
@@ -246,7 +246,13 @@ function getBscArgs(
246
246
}
247
247
248
248
if ( buildSystem === "bsb" ) {
249
- const fileStream = fs . createReadStream ( buildNinjaPath ) ;
249
+ const fileStream = fs . createReadStream ( buildNinjaPath , {
250
+ encoding : "utf8" ,
251
+ } ) ;
252
+ fileStream . on ( "error" , ( err ) => {
253
+ console . error ( "File stream error:" , err ) ;
254
+ resolveResult ( [ ] ) ;
255
+ } ) ;
250
256
const rl = readline . createInterface ( {
251
257
input : fileStream ,
252
258
crlfDelay : Infinity ,
@@ -256,6 +262,7 @@ function getBscArgs(
256
262
let stopped = false ;
257
263
const captured : Array < string > = [ ] ;
258
264
rl . on ( "line" , ( line ) => {
265
+ line = line . trim ( ) ; // Normalize line endings
259
266
if ( stopped ) {
260
267
return ;
261
268
}
@@ -264,7 +271,8 @@ function getBscArgs(
264
271
captureNextLine = false ;
265
272
}
266
273
if ( done ) {
267
- fileStream . destroy ( ) ;
274
+ // Not sure if fileStream.destroy is necessary, rl.close() will handle it gracefully.
275
+ // fileStream.destroy();
268
276
rl . close ( ) ;
269
277
resolveResult ( captured ) ;
270
278
stopped = true ;
@@ -278,6 +286,10 @@ function getBscArgs(
278
286
done = true ;
279
287
}
280
288
} ) ;
289
+ rl . on ( "error" , ( err ) => {
290
+ console . error ( "Readline error:" , err ) ;
291
+ resolveResult ( [ ] ) ;
292
+ } ) ;
281
293
rl . on ( "close" , ( ) => {
282
294
resolveResult ( captured ) ;
283
295
} ) ;
@@ -399,7 +411,7 @@ function triggerIncrementalCompilationOfFile(
399
411
400
412
let originalTypeFileLocation = path . resolve (
401
413
projectRootPath ,
402
- "lib/bs" ,
414
+ c . compilerDirPartialPath ,
403
415
path . relative ( projectRootPath , filePath )
404
416
) ;
405
417
0 commit comments