@@ -390,7 +390,8 @@ exports.main = function main(argv, options, callback) {
390390 if ( ( sourceText = readFile ( sourcePath = internalPath + ".ts" , baseDir ) ) == null ) {
391391 if ( ( sourceText = readFile ( sourcePath = internalPath + "/index.ts" , baseDir ) ) == null ) {
392392 // 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 ) ;
394395 }
395396 }
396397
@@ -478,13 +479,16 @@ exports.main = function main(argv, options, callback) {
478479 var internalPath ;
479480 while ( ( internalPath = assemblyscript . nextFile ( program ) ) != null ) {
480481 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." ) )
482483 stats . parseCount ++ ;
483484 stats . parseTime += measure ( ( ) => {
484485 assemblyscript . parse ( program , file . sourceText , file . sourcePath , false ) ;
485486 } ) ;
486487 }
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+ }
488492 }
489493
490494 // Include runtime template before entry files so its setup runs first
@@ -579,9 +583,10 @@ exports.main = function main(argv, options, callback) {
579583 } catch ( e ) {
580584 return callback ( e ) ;
581585 }
582- if ( checkDiagnostics ( program , stderr ) ) {
586+ var numErrors = checkDiagnostics ( program , stderr ) ;
587+ if ( numErrors ) {
583588 if ( module ) module . dispose ( ) ;
584- return callback ( Error ( "Compile error") ) ;
589+ return callback ( Error ( numErrors + " compile error(s) ") ) ;
585590 }
586591
587592 // Call afterCompile transform hook
@@ -1023,17 +1028,17 @@ exports.main = function main(argv, options, callback) {
10231028/** Checks diagnostics emitted so far for errors. */
10241029function checkDiagnostics ( program , stderr ) {
10251030 var diagnostic ;
1026- var hasErrors = false ;
1031+ var numErrors = 0 ;
10271032 while ( ( diagnostic = assemblyscript . nextDiagnostic ( program ) ) != null ) {
10281033 if ( stderr ) {
10291034 stderr . write (
10301035 assemblyscript . formatDiagnostic ( diagnostic , stderr . isTTY , true ) +
10311036 EOL + EOL
10321037 ) ;
10331038 }
1034- if ( assemblyscript . isError ( diagnostic ) ) hasErrors = true ;
1039+ if ( assemblyscript . isError ( diagnostic ) ) ++ numErrors ;
10351040 }
1036- return hasErrors ;
1041+ return numErrors ;
10371042}
10381043
10391044exports . checkDiagnostics = checkDiagnostics ;
0 commit comments