Skip to content

Commit

Permalink
Handling a few review issues with generateDevelopmentHTML, see #934
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Apr 13, 2020
1 parent d254bd1 commit 70cc7b9
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions js/grunt/generateDevelopmentHTML.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2015-2020, University of Colorado Boulder

/**
* Generates the top-level main HTML file for simulations (or runnables), using the current brand's splash and preloads
* that should be the same as the build-time preloads (minus Google Analytics).
* Generates the top-level main HTML file for simulations (or runnables) using phet-brand splash and loading phet-io
* preloads when brand=phet-io is specified.
*
* See https://github.com/phetsims/chipper/issues/63
*
Expand Down Expand Up @@ -47,29 +47,27 @@ module.exports = async function( repo, options ) {

// Formatting is very specific to the template file. Each preload is placed on separate line,
// with an indentation that is specific indentation to the template. See chipper#462
function stringifyArray( arr, prefix ) {
function stringifyArray( arr, indentation ) {
return '[\n' +
arr.map( function( string ) {
return prefix + ' \'' + string.replace( /'/g, '\\\'' ) + '\'';
} ).join( ',\n' ) +
'\n' + prefix + ' ]';
arr.map( string => indentation + ' \'' + string.replace( /'/g, '\\\'' ) + '\'' ).join( ',\n' ) +
'\n' + indentation + ' ]';
}

function isPreloadExcluded( preload ) {
return preload.includes( 'google-analytics' ) || stripPreloads.includes( preload );
}

const indentLines = string => {
return string.split( '\n' ).join( '\n ' );
};

const preloads = getPreloads( repo, brand, forSim ).filter( preload => {
return !isPreloadExcluded( preload );
} ).concat( addedPreloads );
const phetioPreloads = getPreloads( repo, 'phet-io', forSim ).filter( preload => {
return !isPreloadExcluded( preload ) && !_.includes( preloads, preload );
} );

const indentLines = string => {
return string.split( '\n' ).join( '\n ' );
};

const stringRepos = await getStringRepos( repo );

// Replace placeholders in the template.
Expand Down

0 comments on commit 70cc7b9

Please sign in to comment.