@@ -615,7 +615,7 @@ export async function main(argv, options) {
615
615
stats . parseTime += stats . end ( begin ) ;
616
616
}
617
617
}
618
- const numErrors = checkDiagnostics ( program , stderr , options . reportDiagnostic , stderrColors . enabled ) ;
618
+ const numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
619
619
if ( numErrors ) {
620
620
const err = Error ( `${ numErrors } parse error(s)` ) ;
621
621
err . stack = err . message ; // omit stack
@@ -724,7 +724,7 @@ export async function main(argv, options) {
724
724
? assemblyscript . getBinaryenModuleRef ( module )
725
725
: module . ref
726
726
) ;
727
- var numErrors = checkDiagnostics ( program , stderr , options . reportDiagnostic , stderrColors . enabled ) ;
727
+ var numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
728
728
if ( numErrors ) {
729
729
const err = Error ( `${ numErrors } compile error(s)` ) ;
730
730
err . stack = err . message ; // omit stack
@@ -737,7 +737,7 @@ export async function main(argv, options) {
737
737
if ( error ) return prepareResult ( error ) ;
738
738
}
739
739
740
- numErrors = checkDiagnostics ( program , stderr , options . reportDiagnostic , stderrColors . enabled ) ;
740
+ numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
741
741
if ( numErrors ) {
742
742
const err = Error ( `${ numErrors } afterCompile error(s)` ) ;
743
743
err . stack = err . message ; // omit stack
@@ -1117,17 +1117,23 @@ async function getConfig(file, baseDir, readFile) {
1117
1117
}
1118
1118
1119
1119
/** Checks diagnostics emitted so far for errors. */
1120
- export function checkDiagnostics ( program , stderr , reportDiagnostic , useColors ) {
1120
+ export function checkDiagnostics ( program , stderr , disableWarning , reportDiagnostic , useColors ) {
1121
1121
if ( typeof useColors === "undefined" && stderr ) useColors = stderr . isTTY ;
1122
1122
var numErrors = 0 ;
1123
1123
do {
1124
1124
let diagnostic = assemblyscript . nextDiagnostic ( program ) ;
1125
1125
if ( ! diagnostic ) break ;
1126
1126
if ( stderr ) {
1127
- stderr . write (
1128
- assemblyscript . formatDiagnostic ( diagnostic , useColors , true ) +
1129
- EOL + EOL
1130
- ) ;
1127
+ const checkWarningPrint = ( diagnostic ) => {
1128
+ const code = assemblyscript . getDiagnosticCode ( diagnostic ) ;
1129
+ if ( disableWarning === undefined ) return true ;
1130
+ if ( disableWarning . length === 0 ) return false ;
1131
+ if ( disableWarning . includes ( code ) ) return false ;
1132
+ return true ;
1133
+ }
1134
+ if ( assemblyscript . isError ( diagnostic ) || checkWarningPrint ( diagnostic ) ) {
1135
+ stderr . write ( assemblyscript . formatDiagnostic ( diagnostic , useColors , true ) + EOL + EOL ) ;
1136
+ }
1131
1137
}
1132
1138
if ( reportDiagnostic ) {
1133
1139
function wrapRange ( range ) {
0 commit comments