From cff6eaa81847e828b4116b0a51a1fd9919d56ea8 Mon Sep 17 00:00:00 2001 From: samreid Date: Tue, 7 Sep 2021 09:23:17 -0600 Subject: [PATCH] Improve console messages, see https://github.com/phetsims/chipper/issues/1047 --- js/scripts/hook-pre-commit.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/js/scripts/hook-pre-commit.js b/js/scripts/hook-pre-commit.js index 530784d42..3417be342 100644 --- a/js/scripts/hook-pre-commit.js +++ b/js/scripts/hook-pre-commit.js @@ -127,24 +127,34 @@ catch( e ) { // Run typescript type checker if it exists in the checked-out shas try { const isRepoTypeScript = require( '../../../perennial-alias/js/common/isRepoTypeScript' ); - const tsc = require( '../../../chipper/js/grunt/tsc' ); - if ( isRepoTypeScript.apiVersion === '1.0' && tsc.apiVersion === '1.0' && - isRepoTypeScript( repo ) ) { - ( async () => { - const results = await tsc( `../${repo}`, [] ); - - if ( results.code === 0 ) { - outputToConsole && console.log( 'tsc passed' ); + if ( isRepoTypeScript.apiVersion === '1.0' ) { + if ( isRepoTypeScript( repo ) ) { + + const tsc = require( '../../../chipper/js/grunt/tsc' ); + if ( tsc.apiVersion === '1.0' ) { + ( async () => { + const results = await tsc( `../${repo}`, [] ); + + if ( results.code === 0 ) { + outputToConsole && console.log( 'tsc passed' ); + } + else { + console.log( results ); + process.exit( results.code ); + } + } )(); } else { - console.log( results ); - process.exit( results.code ); + outputToConsole && console.log( 'chipper/js/grunt/tsc not compatible' ); } - } )(); + } + else { + outputToConsole && console.log( 'skipping tsc for non-typescript repo' ); + } } else { - console.log( 'chipper/js/grunt/tsc not compatible' ); + outputToConsole && console.log( 'isRepoTypeScript not compatible' ); } } catch( e ) {