From 9b602d8fe4aae4915c2a9c1f05065563ca7c9892 Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Tue, 5 Dec 2017 10:41:10 -0700 Subject: [PATCH] Improving how brands are handled, see https://github.com/phetsims/chipper/issues/592 --- js/grunt/Gruntfile.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/js/grunt/Gruntfile.js b/js/grunt/Gruntfile.js index 56c97596..67e79c46 100644 --- a/js/grunt/Gruntfile.js +++ b/js/grunt/Gruntfile.js @@ -83,29 +83,30 @@ module.exports = function( grunt ) { // Determine what brands we want to build assert( !grunt.option( 'brand' ), 'Use --brands={{BRANDS}} instead of brand' ); + const localPackageObject = grunt.file.readJSON( `../${repo}/package.json` ); + const supportedBrands = localPackageObject.phet.supportedBrands; + + assert( localPackageObject.phet.runnable, `${repo} does not appear to be runnable` ); + var brands; if ( grunt.option( 'brands' ) ) { if ( grunt.option( 'brands' ) === '*' ) { - brands = ChipperConstants.BRANDS; + brands = supportedBrands; } else { brands = grunt.option( 'brands' ).split( ',' ); } } else if ( buildLocal.brands ) { - brands = buildLocal.brands; + brands = buildLocal.brands.filter( brand => localPackageObject.phet.supportedBrands.includes( brand ) ); } else { brands = [ 'adapted-from-phet' ]; } // Ensure all listed brands are valid - brands.forEach( brand => assert( ChipperConstants.BRANDS.includes( brand, `Unknown brand: ${brand}` ) ) ); - - // Filter out brands that aren't supported by the given runnable - const localPackageObject = grunt.file.readJSON( `../${repo}/package.json` ); - assert( localPackageObject.phet.runnable, `${repo} does not appear to be runnable` ); - brands = brands.filter( brand => localPackageObject.phet.supportedBrands.includes( brand ) ); + brands.forEach( brand => assert( ChipperConstants.BRANDS.includes( brand ), `Unknown brand: ${brand}` ) ); + brands.forEach( brand => assert( supportedBrands.includes( brand ), `Unsupported brand: ${brand}` ) ); // Other options const allHTML = !!grunt.option( 'allHTML' );