Skip to content

Commit

Permalink
add test grunt task, add todos, #1437
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kauzmann <[email protected]>
  • Loading branch information
zepumph committed May 15, 2024
1 parent 83461d2 commit 572c2d3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
8 changes: 5 additions & 3 deletions js/common/Transpiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const subdirs = [ 'js', 'images', 'mipmaps', 'sounds', 'shaders', 'common', 'wgs
const getActiveRepos = () => fs.readFileSync( '../perennial-alias/data/active-repos', 'utf8' ).trim().split( '\n' ).map( sim => sim.trim() );

const getModesForRepo = repo => {
// TODO: Duplicated repos in grunMain.js https://github.com/phetsims/chipper/issues/1437
const dualRepos = [ 'chipper', 'perennial-alias', 'perennial', 'phet-core' ];
if ( dualRepos.includes( repo ) ) {
return [ 'js', 'commonjs' ];
Expand Down Expand Up @@ -485,6 +486,7 @@ class Transpiler {

if ( !pathExists ) {

// TODO: This should be a constant for "all supported modes" https://github.com/phetsims/chipper/issues/1437
const modes = [ 'js', 'commonjs' ];

modes.forEach( mode => {
Expand Down Expand Up @@ -520,10 +522,10 @@ class Transpiler {
}
else {
const terms = filename.split( path.sep );
const myRepo = terms[ 0 ];
if ( ( this.activeRepos.includes( myRepo ) || this.repos.includes( myRepo ) )
const repo = terms[ 0 ];
if ( ( this.activeRepos.includes( repo ) || this.repos.includes( repo ) )
&& subdirs.includes( terms[ 1 ] ) && pathExists ) {
this.visitFile( filePath, getModesForRepo( myRepo ) );
this.visitFile( filePath, getModesForRepo( repo ) );
}
}
} );
Expand Down
4 changes: 4 additions & 0 deletions js/grunt/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ module.exports = function( grunt ) {
} )
);

grunt.registerTask( 'typescript-test', 'For testing typescript in our build tools', wrapTask( async () => {
require( './typescript-test' );
} ) );

grunt.registerTask( 'build',
`Builds the repository. Depending on the repository type (runnable/wrapper/standalone), the result may vary.
Runnable build options:
Expand Down
3 changes: 2 additions & 1 deletion js/grunt/gruntMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/* eslint-env node */

// Switch between TypeScript and JavaScript
// Switch between TypeScript and JavaScript (feature flag)
const LAUNCH_FROM_CHIPPER_DIST = false;

if ( LAUNCH_FROM_CHIPPER_DIST ) {
Expand All @@ -38,6 +38,7 @@ if ( LAUNCH_FROM_CHIPPER_DIST ) {
commonJSTranspiler.transpileRepoWithModes( 'chipper', [ 'commonjs' ] );
commonJSTranspiler.transpileRepoWithModes( 'phet-core', [ 'commonjs' ] );
commonJSTranspiler.transpileRepoWithModes( 'perennial-alias', [ 'commonjs' ] );
commonJSTranspiler.transpileRepoWithModes( 'perennial', [ 'commonjs' ] ); // TODO: needed by aqua/ https://github.com/phetsims/chipper/issues/1437
commonJSTranspiler.saveCache();

// TODO: Make sure the above repos are covered by tsconfig/all, see https://github.com/phetsims/chipper/issues/1437
Expand Down
11 changes: 11 additions & 0 deletions js/grunt/typescript-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2024, University of Colorado Boulder

/**
* TODO: delete as part of https://github.com/phetsims/chipper/issues/1437
* @author Michael Kauzmann (PhET Interactive Simulations)
* @author Sam Reid (PhET Interactive Simulations)
*/

const myTestNumber: number = 9;

console.log( myTestNumber );

0 comments on commit 572c2d3

Please sign in to comment.