@@ -2,12 +2,12 @@ import pathlib from 'path';
22import chalk from 'chalk' ;
33import partition from 'lodash/partition.js' ;
44import ts from 'typescript' ;
5- import type { OverallResultType , FormattableTscResult , JsonResult } from '@sourceacademy/modules-repotools/build' ;
5+ import type { OverallResultType , FormattableTscResult } from '@sourceacademy/modules-repotools/build' ;
6+ import type { LintResult } from '@sourceacademy/modules-repotools/prebuild/lint' ;
67
78interface ResultsObject {
89 tsc ?: FormattableTscResult ;
910 lint : LintResult ;
10- results ?: OverallResultType ;
1111}
1212
1313export function formatLintResult ( { severity, formatted, input } : LintResult ) : string {
@@ -23,27 +23,6 @@ export function formatLintResult({ severity, formatted, input }: LintResult): st
2323 }
2424}
2525
26- /**
27- * Formats a single result object into a string
28- */
29- export function formatResult ( result : OverallResultType ) {
30- if ( result . severity === 'error' ) {
31- return result . errors . join ( '\n' ) ;
32- }
33-
34- const typeStr = type ?? 'output' ;
35- const successStr = chalk . greenBright ( `${ typeStr } written to ${ result . path } ` ) ;
36-
37- if ( result . severity === 'warn' ) {
38- return [
39- ...result . warnings ,
40- successStr
41- ] . join ( '\n' ) ;
42- }
43-
44- return successStr ;
45- }
46-
4726export function formatTscResult ( tscResult : FormattableTscResult ) : string {
4827 const prefix = chalk . cyanBright ( 'tsc completed' ) ;
4928
@@ -80,18 +59,22 @@ export function formatTscResult(tscResult: FormattableTscResult): string {
8059/**
8160 * Formats a larger result object, particularly one with prebuild results too.
8261 */
83- export function formatResultObject ( results : ResultsObject ) : string {
62+ export function formatResultObject ( { tsc , lint } : ResultsObject , result : OverallResultType ) : string {
8463 const args : string [ ] = [ ] ;
8564
86- if ( results . tsc ) {
87- args . push ( formatTscResult ( results . tsc ) ) ;
65+ if ( tsc ) {
66+ args . push ( formatTscResult ( tsc ) ) ;
8867 }
8968
90- if ( results . lint ) {
91- args . push ( formatLintResult ( results . lint ) ) ;
69+ if ( lint ) {
70+ args . push ( formatLintResult ( lint ) ) ;
71+ }
72+
73+ if ( result . severity === 'error' ) {
74+ result . diagnostics !== undefined
9275 }
9376
94- if ( results . results !== undefined ) {
77+ if ( result . diagnostics !== undefined ) {
9578 args . push ( formatResult ( results . results ) ) ;
9679 }
9780
0 commit comments