Skip to content

Commit

Permalink
Convert to TypeScript, see #1465
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Oct 15, 2024
1 parent f256ebe commit d584942
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
3 changes: 2 additions & 1 deletion js/grunt/buildRunnable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import getInitializationScript from './getInitializationScript';
import packageXHTML from './packageXHTML';
import reportUnusedStrings from './reportUnusedStrings';
import getDependencies from './getDependencies';
import getLocalesFromRepository from './getLocalesFromRepository';

const assert = require( 'assert' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
Expand All @@ -23,7 +24,7 @@ const copyDirectory = require( './copyDirectory' );
const copySupplementalPhetioFiles = require( './copySupplementalPhetioFiles' );
const getA11yViewHTMLFromTemplate = require( './getA11yViewHTMLFromTemplate' );
const getAllThirdPartyEntries = require( './getAllThirdPartyEntries' );
const getLocalesFromRepository = require( './getLocalesFromRepository' );

const getPhetLibs = require( './getPhetLibs' );
const getPreloads = require( './getPreloads' );
const getPrunedLocaleData = require( './getPrunedLocaleData' );
Expand Down
3 changes: 2 additions & 1 deletion js/grunt/buildStandalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import webpackBuild from './webpackBuild';
import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.ts';
import getLocalesFromRepository from './getLocalesFromRepository';

const assert = require( 'assert' );
const fs = require( 'fs' );
Expand All @@ -16,7 +17,7 @@ const minify = require( './minify' );
const _ = require( 'lodash' );
const getStringMap = require( './getStringMap' );
const ChipperConstants = require( '../common/ChipperConstants' );
const getLocalesFromRepository = require( './getLocalesFromRepository' );

const getPhetLibs = require( './getPhetLibs' );

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
// Copyright 2017-2024, University of Colorado Boulder

/**
* @author Chris Malley (PixelZoom, Inc.)
* @author Jonathan Olson <jonathan.olson@colorado.edu>
*/


const assert = require( 'assert' );
const grunt = require( 'grunt' );

/*
/**
* Gets the locales from a repository, by inspecting the names of the string files in babel for that repository.
* @public
*
* @param {string} repo - name of the repository to get locales from
* @param repo - name of the repository to get locales from
*
* @author Chris Malley (PixelZoom, Inc.)
* @author Jonathan Olson <jonathan.olson@colorado.edu>
*/
module.exports = function( repo ) {
export default function( repo: string ): string[] {

// confirm that the repository has a strings directory
const stringsDirectory = `../babel/${repo}`;
assert( grunt.file.isDir(), `${stringsDirectory} is not a directory` );

// Get names of string files.
const stringFiles = grunt.file.expand( `${stringsDirectory}/${repo}-strings_*.json` );
const stringFiles: string[] = grunt.file.expand( `${stringsDirectory}/${repo}-strings_*.json` );

// Don't fail out if there are no string files, as this is a normal condition when building new simulations
if ( stringFiles.length === 0 ) {
Expand All @@ -38,4 +34,4 @@ module.exports = function( repo ) {
assert( locales.length > 0, `no locales found in ${stringsDirectory}` );

return locales;
};
}
3 changes: 2 additions & 1 deletion js/grunt/tasks/generate-used-strings-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import getRepo from '../../../../perennial-alias/js/grunt/tasks/util/getRepo';
import webpackBuild from '../webpackBuild';
import getLocalesFromRepository from '../getLocalesFromRepository';

const getPhetLibs = require( '../getPhetLibs' );
const fs = require( 'fs' );
const ChipperConstants = require( '../../common/ChipperConstants' );
const getLocalesFromRepository = require( '../getLocalesFromRepository' );

const getStringMap = require( '../getStringMap' );

/**
Expand Down

0 comments on commit d584942

Please sign in to comment.