@@ -390,7 +390,8 @@ exports.main = function main(argv, options, callback) {
390
390
if ( ( sourceText = readFile ( sourcePath = internalPath + ".ts" , baseDir ) ) == null ) {
391
391
if ( ( sourceText = readFile ( sourcePath = internalPath + "/index.ts" , baseDir ) ) == null ) {
392
392
// portable d.ts: uses the .js file next to it in JS or becomes an import in Wasm
393
- sourceText = readFile ( sourcePath = internalPath + ".d.ts" , baseDir ) ;
393
+ sourcePath = internalPath + ".ts" ;
394
+ sourceText = readFile ( internalPath + ".d.ts" , baseDir ) ;
394
395
}
395
396
}
396
397
@@ -478,13 +479,16 @@ exports.main = function main(argv, options, callback) {
478
479
var internalPath ;
479
480
while ( ( internalPath = assemblyscript . nextFile ( program ) ) != null ) {
480
481
let file = getFile ( internalPath , assemblyscript . getDependee ( program , internalPath ) ) ;
481
- if ( ! file ) return callback ( Error ( "Import file '" + internalPath + ".ts ' not found." ) )
482
+ if ( ! file ) return callback ( Error ( "Import '" + internalPath + "' not found." ) )
482
483
stats . parseCount ++ ;
483
484
stats . parseTime += measure ( ( ) => {
484
485
assemblyscript . parse ( program , file . sourceText , file . sourcePath , false ) ;
485
486
} ) ;
486
487
}
487
- if ( checkDiagnostics ( program , stderr ) ) return callback ( Error ( "Parse error" ) ) ;
488
+ var numErrors = checkDiagnostics ( program , stderr ) ;
489
+ if ( numErrors ) {
490
+ return callback ( Error ( numErrors + " parse error(s)" ) ) ;
491
+ }
488
492
}
489
493
490
494
// Include runtime template before entry files so its setup runs first
@@ -579,9 +583,10 @@ exports.main = function main(argv, options, callback) {
579
583
} catch ( e ) {
580
584
return callback ( e ) ;
581
585
}
582
- if ( checkDiagnostics ( program , stderr ) ) {
586
+ var numErrors = checkDiagnostics ( program , stderr ) ;
587
+ if ( numErrors ) {
583
588
if ( module ) module . dispose ( ) ;
584
- return callback ( Error ( "Compile error") ) ;
589
+ return callback ( Error ( numErrors + " compile error(s) ") ) ;
585
590
}
586
591
587
592
// Call afterCompile transform hook
@@ -1023,17 +1028,17 @@ exports.main = function main(argv, options, callback) {
1023
1028
/** Checks diagnostics emitted so far for errors. */
1024
1029
function checkDiagnostics ( program , stderr ) {
1025
1030
var diagnostic ;
1026
- var hasErrors = false ;
1031
+ var numErrors = 0 ;
1027
1032
while ( ( diagnostic = assemblyscript . nextDiagnostic ( program ) ) != null ) {
1028
1033
if ( stderr ) {
1029
1034
stderr . write (
1030
1035
assemblyscript . formatDiagnostic ( diagnostic , stderr . isTTY , true ) +
1031
1036
EOL + EOL
1032
1037
) ;
1033
1038
}
1034
- if ( assemblyscript . isError ( diagnostic ) ) hasErrors = true ;
1039
+ if ( assemblyscript . isError ( diagnostic ) ) ++ numErrors ;
1035
1040
}
1036
- return hasErrors ;
1041
+ return numErrors ;
1037
1042
}
1038
1043
1039
1044
exports . checkDiagnostics = checkDiagnostics ;
0 commit comments