@@ -19,7 +19,10 @@ function debug() {
19
19
}
20
20
21
21
const INCREMENTAL_FOLDER_NAME = "___incremental" ;
22
- const INCREMENTAL_FILE_FOLDER_LOCATION = `lib/bs/${ INCREMENTAL_FOLDER_NAME } ` ;
22
+ const INCREMENTAL_FILE_FOLDER_LOCATION = path . join (
23
+ c . compilerDirPartialPath ,
24
+ INCREMENTAL_FOLDER_NAME
25
+ ) ;
23
26
24
27
type RewatchCompilerArgs = {
25
28
compiler_args : Array < string > ;
@@ -190,11 +193,11 @@ function getBscArgs(
190
193
) : Promise < Array < string > | RewatchCompilerArgs | null > {
191
194
const buildNinjaPath = path . resolve (
192
195
entry . project . rootPath ,
193
- "lib/bs/build.ninja"
196
+ c . buildNinjaPartialPath
194
197
) ;
195
198
const rewatchLockfile = path . resolve (
196
199
entry . project . workspaceRootPath ,
197
- "lib/rewatch.lock"
200
+ c . rewatchLockPartialPath
198
201
) ;
199
202
let buildSystem : "bsb" | "rewatch" | null = null ;
200
203
@@ -246,7 +249,13 @@ function getBscArgs(
246
249
}
247
250
248
251
if ( buildSystem === "bsb" ) {
249
- const fileStream = fs . createReadStream ( buildNinjaPath ) ;
252
+ const fileStream = fs . createReadStream ( buildNinjaPath , {
253
+ encoding : "utf8" ,
254
+ } ) ;
255
+ fileStream . on ( "error" , ( err ) => {
256
+ console . error ( "File stream error:" , err ) ;
257
+ resolveResult ( [ ] ) ;
258
+ } ) ;
250
259
const rl = readline . createInterface ( {
251
260
input : fileStream ,
252
261
crlfDelay : Infinity ,
@@ -256,6 +265,7 @@ function getBscArgs(
256
265
let stopped = false ;
257
266
const captured : Array < string > = [ ] ;
258
267
rl . on ( "line" , ( line ) => {
268
+ line = line . trim ( ) ; // Normalize line endings
259
269
if ( stopped ) {
260
270
return ;
261
271
}
@@ -264,7 +274,8 @@ function getBscArgs(
264
274
captureNextLine = false ;
265
275
}
266
276
if ( done ) {
267
- fileStream . destroy ( ) ;
277
+ // Not sure if fileStream.destroy is necessary, rl.close() will handle it gracefully.
278
+ // fileStream.destroy();
268
279
rl . close ( ) ;
269
280
resolveResult ( captured ) ;
270
281
stopped = true ;
@@ -278,6 +289,10 @@ function getBscArgs(
278
289
done = true ;
279
290
}
280
291
} ) ;
292
+ rl . on ( "error" , ( err ) => {
293
+ console . error ( "Readline error:" , err ) ;
294
+ resolveResult ( [ ] ) ;
295
+ } ) ;
281
296
rl . on ( "close" , ( ) => {
282
297
resolveResult ( captured ) ;
283
298
} ) ;
@@ -399,7 +414,7 @@ function triggerIncrementalCompilationOfFile(
399
414
400
415
let originalTypeFileLocation = path . resolve (
401
416
projectRootPath ,
402
- "lib/bs" ,
417
+ c . compilerDirPartialPath ,
403
418
path . relative ( projectRootPath , filePath )
404
419
) ;
405
420
@@ -512,13 +527,13 @@ async function figureOutBscArgs(entry: IncrementallyCompiledFileInfo) {
512
527
if ( isBsb ) {
513
528
callArgs . push (
514
529
"-I" ,
515
- path . resolve ( entry . project . rootPath , "lib/bs" , value )
530
+ path . resolve ( entry . project . rootPath , c . compilerDirPartialPath , value )
516
531
) ;
517
532
} else {
518
533
if ( value === "." ) {
519
534
callArgs . push (
520
535
"-I" ,
521
- path . resolve ( entry . project . rootPath , "lib/ocaml" )
536
+ path . resolve ( entry . project . rootPath , c . compilerOcamlDirPartialPath )
522
537
) ;
523
538
} else {
524
539
callArgs . push ( "-I" , value ) ;
0 commit comments