diff --git a/js/grunt/Gruntfile.js b/js/grunt/Gruntfile.js index acd4b238..34ff2400 100644 --- a/js/grunt/Gruntfile.js +++ b/js/grunt/Gruntfile.js @@ -151,7 +151,7 @@ Minify-specific options: --minify.stripAssertions=false - During uglification, it will strip assertions. --minify.stripLogging=false - During uglification, it will not strip logging statements. `, - wrapExecSync( `node ../chipper/js/grunt/tasks/build.js --repo ${repo}` ) + wrapExecSync( `node ../chipper/js/grunt/tasks/build.js --repo ${repo} ${process.argv.slice( 2 ).join( ' ' )}` ) ); grunt.registerTask( 'generate-used-strings-file', diff --git a/js/grunt/tasks/build.js b/js/grunt/tasks/build.js index 6aeda55b..fb56c45c 100644 --- a/js/grunt/tasks/build.js +++ b/js/grunt/tasks/build.js @@ -20,6 +20,25 @@ const assert = require( 'assert' ); const Transpiler = require( '../../common/Transpiler' ); const getBrands = require( './getBrands' ); +// Like minimist, process into an object literal which can be consumed by grunt.option.init +function parseArgs( argv ) { + const args = {}; + argv.forEach( ( arg, index ) => { + if ( arg.startsWith( '--' ) ) { + const key = arg.slice( 2 ); + const value = argv[ index + 1 ] && !argv[ index + 1 ].startsWith( '--' ) ? argv[ index + 1 ] : true; + args[ key ] = value; + } + } ); + return args; +} + +// Parse argv +const parsedArgs = parseArgs( process.argv.slice( 2 ) ); + +// Initialize Grunt options with parsed arguments +grunt.option.init( parsedArgs ); + const repo = getRequiredArg( '--repo' ); const transpiler = new Transpiler( { silent: true } );